2011-12-29 107 views
1

我從我的移動設備中獲取播放列表,並在列表視圖中顯示我的歌曲以及多個複選框。現在,我需要保存複選框的狀態,當用戶再次啓動應用程序時,將重新加載複選框。您可以建議如何完成此操作? ?在android中的listview中保存複選框狀態?

從系統中獲取播放歌曲...代碼我寫的是:

ListView list = (ListView) findViewById(R.id.songlist); 
String[] projection = { MediaStore.Audio.Playlists.Members._ID, 
       MediaStore.Audio.Playlists.Members.TITLE, 
       MediaStore.Audio.Playlists.Members.DATA, 
       MediaStore.Audio.Playlists.Members.AUDIO_ID, 
       MediaStore.Audio.Playlists.Members.ARTIST }; 

    Cursor cursor = managedQuery(
      // 1 is the id of playlist MediaStore.Audio.Playlists.Members.getContentUri("external", 1), projection, 
       MediaStore.Audio.Media.IS_MUSIC + " != 0 ", null, null); 

SimpleCursorAdapter a = new SimpleCursorAdapter(this, R.layout.list_item, cursor, 
       new String[] { MediaStore.Audio.Playlists.Members.TITLE }, new int[] { R.id.checkbox }); 
     this.setListAdapter(a); 
     list.setAdapter(a); 

回答