Help with Populating List with ListAdapter

Discussion in 'Android App Developers' started by r2sjoblom, Dec 15, 2011.

  1. r2sjoblom

    r2sjoblom New Member

    Joined:
    Feb 24, 2011
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    Ratings:
    +0
    I am having a bit of a problem with populating a list from a RingtoneManager to a new ListActivity. The list populates with the correct number of items in the directory but doesn't show the titles or any text. Using the Log.d(); I can see the items are being pulled properly but not displaying. Any guidance would be appreciated.

    mRingtoneManager2 = new RingtoneManager(this); //adds ringtonemanager
    mRingtoneManager2.setType(RingtoneManager.TYPE_RINGTONE); //sets the type to ringtones
    mRingtoneManager2.setIncludeDrm(true); //get list of ringtones to include DRM
    mCursor2 = mRingtoneManager2.getCursor(); //appends my cursor to the ringtonemanager
    startManagingCursor​
    mCursor2); //starts the cursor query
    //prints output for diagnostics
    String test = ​
    mCursor2.getString(mCursor2.getColumnIndexOrThrow(RingtoneManager.EXTRA_RINGTONE_TITLE));
    Log.d(
    null, test, null);
    String[] from = {RingtoneManager.
    EXTRA_RINGTONE_TITLE}; // get the list items for the listadapter
    int[] to = newint[] {R.id.item1}; //sets the items from above string to listview
    //new listadapter, created to use android checked template
    SimpleCursorAdapter listadapter = ​
    new SimpleCursorAdapter(this, android.R.layout.simple_list_item_checked, mCursor2, from, to );
    setListAdapter(listadapter);

     
  2. r2sjoblom

    r2sjoblom New Member

    Joined:
    Feb 24, 2011
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    Ratings:
    +0
    Got it! Im posting what I needed to help anyone else.

    mRingtoneManager2 = new RingtoneManager(this); //adds ringtonemanager
    mRingtoneManager2.setType(RingtoneManager.TYPE_RINGTONE); //sets the type to ringtones
    mRingtoneManager2.setIncludeDrm(true); //get list of ringtones to include DRM
    mCursor2 = mRingtoneManager2.getCursor(); //appends my cursor to the ringtonemanager
    startManagingCursor(​
    mCursor2); //starts the cursor query
    //prints output for diagnostics
    String test = ​
    mCursor2.getString(mCursor2.getColumnIndexOrThrow(RingtoneManager.EXTRA_RINGTONE_TITLE));Log.d(null, test, null);String[] from = {mCursor2.getColumnName(RingtoneManager.TITLE_COLUMN_INDEX), mCursor2.getColumnName(RingtoneManager.URI_COLUMN_INDEX)}; // get the list items for the listadapter could be TITLE or URI
    int[] to = {android.R.id.text1, android.R.id.text2}; //sets the items from above string to listview
    //new listadapter, created to use android checked template
    SimpleCursorAdapter listadapter = ​
    new SimpleCursorAdapter(this, android.R.layout.simple_list_item_2, mCursor2, from, to );setListAdapter(listadapter);//prints output for diagnostics
    String test2 = listadapter.toString();Log.d(​
    null, test2, null);//adds listview so I can get data from it
    ListView lv = getListView();

     
Search tags for this page

android.r.layout.simple list item checked remember the last