What's new
DroidForums.net | Android Forum & News

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Help with Populating List with ListAdapter

r2sjoblom

New Member
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);
 
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();
 
Back
Top