0

I just need to delete an item from this list, I already have the index that I want but can not find a way to delete.

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);
Eugene S
  • 3,092
  • 18
  • 34

2 Answers2

0

First remove item from your songsListData Collection and reload the list view.

Dhruba Bose
  • 446
  • 2
  • 7
0

If you already have the index, try these songsListData.remove(index); adapter.notifyDataSetChanged(); maybe in onItemClick

Euporie
  • 1,896
  • 1
  • 21
  • 23