2014-09-09 3 views
0

이 목록에서 항목을 삭제하기 만하면됩니다. 이미 원하는 색인이 있지만 삭제할 방법을 찾을 수 없습니다.목록보기 항목을 아래 코드로 삭제하는 방법은 무엇입니까?

ArrayList<HashMap<String, String>> songsListData = new ArrayList<HashMap<String, String>>(); 
SongsManager plm = new SongsManager(); 

// get all songs from sdcard 
this.songsList = plm.getPlayList(); 

// looping through playlist 
for (int i = 0; i < songsList.size(); i++) { 
    // creating new HashMap 
    HashMap<String, String> song = songsList.get(i); 

    // adding HashList to ArrayList 
    songsListData.add(song); 
} 

// Adding menuItems to ListView 
ListAdapter adapter = new SimpleAdapter(
    this, 
    songsListData, 
    R.layout.playlist_item, 
    new String[] { "songTitle" }, 
    new int[] { R.id.songTitle2 }); 

setListAdapter(adapter); 

답변

0

이미 인덱스가있는 경우, 어쩌면

+0

내 어댑터 옵션 "notifyDataSetChanged()"를 가지고 onItemClick 이러한 songsListData.remove(index); adapter.notifyDataSetChanged(); 을 시도합니다. :/ –

+0

songsListData.remove (aux); \t \t \t \t ((BaseAdapter) 어댑터) .notifyDataSetChanged(); 이제는 sdcard를 움직일 수 없다. –

+0

String selectedFilePath = songsList2.get (aux) .get ("songPath"); \t \t \t \t 파일 파일 = 새 파일 (selectedFilePath); \t \t \t \t file.delete(); 지금 예 !!! : D –

0

먼저 SongListData Collection에서 항목을 제거하고 목록보기를 다시로드하십시오.

관련 문제