0
道歉,如果我錯過了一些非常簡單的東西,我對編程很陌生。什麼是Mediastore對象的一個很好的simpleCursorAdapter實現?
我正在嘗試構建媒體播放器,並且已經發現並使用MediaStore.Audio來收集播放列表的媒體。我現在需要實現一個適配器以將其置入列表視圖供用戶選擇。我覺得這可能是實現簡單曲目列表最優雅的方式。
到目前爲止,我有:
SimpleCursorAdapter myAdapter;
String[] STAR = { "*" };
Uri allsongsuri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
String selection = MediaStore.Audio.Media.IS_MUSIC + " != 0";
Cursor cursor = getContentResolver().query(allsongsuri, STAR, selection, null, null);
if (cursor != null) {
if (cursor.moveToFirst()) {
do {
String song_name = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.DISPLAY_NAME));
int song_id = cursor.getInt(cursor.getColumnIndex(MediaStore.Audio.Media._ID));
String fullpath = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.DATA));
String album_name = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.ALBUM));
int album_id = cursor.getInt(cursor.getColumnIndex(MediaStore.Audio.Media.ALBUM_ID));
String artist_name = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.ARTIST));
int artist_id = cursor.getInt(cursor.getColumnIndex(MediaStore.Audio.Media.ARTIST_ID));
} while (cursor.moveToNext());
}
cursor.close();
}
}
我現在正在使用simpleCursorAdaptor到ListView的,但不知道如何去了解它,或者把它放在哪裏。任何幫助將不勝感激。
感謝您的時間,一旦我根據此建議嘗試了更多的東西,我會更新此主題的更多細節。似乎有幾種方法可以解決它! –