Search in sources :

Example 16 with SimpleCursorAdapter

use of android.widget.SimpleCursorAdapter in project cw-android by commonsguy.

the class ConstantsBrowser method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    db = new DatabaseHelper(this);
    constantsCursor = db.getReadableDatabase().rawQuery("SELECT _ID, title, value " + "FROM constants ORDER BY title", null);
    ListAdapter adapter = new SimpleCursorAdapter(this, R.layout.row, constantsCursor, new String[] { DatabaseHelper.TITLE, DatabaseHelper.VALUE }, new int[] { R.id.title, R.id.value });
    setListAdapter(adapter);
    registerForContextMenu(getListView());
}
Also used : SimpleCursorAdapter(android.widget.SimpleCursorAdapter) ListAdapter(android.widget.ListAdapter)

Example 17 with SimpleCursorAdapter

use of android.widget.SimpleCursorAdapter in project cw-advandroid by commonsguy.

the class OldContactsAdapterBridge method buildPhonesAdapter.

SpinnerAdapter buildPhonesAdapter(Activity a) {
    String[] PROJECTION = new String[] { Contacts.Phones._ID, Contacts.Phones.NAME, Contacts.Phones.NUMBER };
    String[] ARGS = { String.valueOf(Contacts.Phones.TYPE_MOBILE) };
    Cursor c = a.managedQuery(Contacts.Phones.CONTENT_URI, PROJECTION, Contacts.Phones.TYPE + "=?", ARGS, Contacts.Phones.NAME);
    SimpleCursorAdapter adapter = new SimpleCursorAdapter(a, android.R.layout.simple_spinner_item, c, new String[] { Contacts.Phones.NAME }, new int[] { android.R.id.text1 });
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    return (adapter);
}
Also used : SimpleCursorAdapter(android.widget.SimpleCursorAdapter) Cursor(android.database.Cursor)

Example 18 with SimpleCursorAdapter

use of android.widget.SimpleCursorAdapter in project BeyondUPnP by kevinshine.

the class PlaylistFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_playlist, container, false);
    // Create an empty adapter we will use to display the loaded data.
    mAdapter = new SimpleCursorAdapter(getActivity(), android.R.layout.simple_list_item_activated_1, null, new String[] { PlaylistItem.ITEM_TITLE }, new int[] { android.R.id.text1 }, 0);
    mListView = (ListView) view.findViewById(android.R.id.list);
    mListView.setAdapter(mAdapter);
    mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
    mListView.setMultiChoiceModeListener(new MultipleModeCallback());
    mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Cursor cursor = (Cursor) mAdapter.getItem(position);
            String itemUri = cursor.getString(cursor.getColumnIndex(PlaylistItem.ITEM_URI));
            String metadata = cursor.getString(cursor.getColumnIndex(PlaylistItem.ITEM_METADATA));
            PlaybackCommand.playNewItem(itemUri, metadata);
        }
    });
    return view;
}
Also used : SimpleCursorAdapter(android.widget.SimpleCursorAdapter) AdapterView(android.widget.AdapterView) Cursor(android.database.Cursor) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView)

Example 19 with SimpleCursorAdapter

use of android.widget.SimpleCursorAdapter in project android-support-v4-googlemaps by petedoyle.

the class CursorFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    // Give some text to display if there is no data.  In a real
    // application this would come from a resource.
    setEmptyText("No phone numbers");
    // We have a menu item to show in action bar.
    setHasOptionsMenu(true);
    // Create an empty adapter we will use to display the loaded data.
    mAdapter = new SimpleCursorAdapter(getActivity(), android.R.layout.simple_list_item_2, null, new String[] { Contacts.DISPLAY_NAME, Contacts.CONTACT_STATUS }, new int[] { android.R.id.text1, android.R.id.text2 }, 0);
    setListAdapter(mAdapter);
    // Start out with a progress indicator.
    setListShown(false);
    // Prepare the loader.  Either re-connect with an existing one,
    // or start a new one.
    getLoaderManager().initLoader(0, null, this);
}
Also used : SimpleCursorAdapter(android.widget.SimpleCursorAdapter)

Example 20 with SimpleCursorAdapter

use of android.widget.SimpleCursorAdapter in project robolectric by robolectric.

the class ShadowSimpleCursorAdapterTest method testSwapCursorToNull.

@Test
public void testSwapCursorToNull() {
    SimpleCursorAdapter adapter = new SimpleCursorAdapter(RuntimeEnvironment.application, 1, null, new String[] { "name" }, new int[] { 2 }, 0);
    Cursor cursor = setUpDatabase();
    adapter.swapCursor(cursor);
    adapter.swapCursor(null);
    assertThat(adapter.getCursor()).isNull();
}
Also used : SimpleCursorAdapter(android.widget.SimpleCursorAdapter) Cursor(android.database.Cursor) Test(org.junit.Test)

Aggregations

SimpleCursorAdapter (android.widget.SimpleCursorAdapter)60 Cursor (android.database.Cursor)37 ListAdapter (android.widget.ListAdapter)16 ListView (android.widget.ListView)13 AlphaAnimation (android.view.animation.AlphaAnimation)6 Animation (android.view.animation.Animation)6 AnimationSet (android.view.animation.AnimationSet)6 LayoutAnimationController (android.view.animation.LayoutAnimationController)6 TranslateAnimation (android.view.animation.TranslateAnimation)6 View (android.view.View)4 Test (org.junit.Test)3 Intent (android.content.Intent)2 Uri (android.net.Uri)2 TextView (android.widget.TextView)2 ContentResolver (android.content.ContentResolver)1 ContentValues (android.content.ContentValues)1 MatrixCursor (android.database.MatrixCursor)1 Drawable (android.graphics.drawable.Drawable)1 OnClickListener (android.view.View.OnClickListener)1 LayoutParams (android.view.ViewGroup.LayoutParams)1