tags:

views:

42

answers:

0

I am working on a music player where I store the current play queue in an arraylist and users can click a little button to view the current play queue. In the AlertDialog they can click on one of the items to jump to that song in the queue and additionally, I have an ImageButton that allows them to remove items from the play queue. I am convinced that there is a bug in AlertDialog though... because when I click on the remove button the item is removed from the ArrayList just fine... but when I call notifyDataSetChanged() the listview just disappears from the dialog. I can even call getCount() on the listview and it returns the correct count but as I said... it just disappears from the AlertDialog. Is there a way to address this or will I be forced to create an actvity to accomplish my goal?

currentPlaylist.remove(position);
mCurrentPlaylistAdapter.setSongList(currentPlaylist); // calls notifyDataSetChanged()
playlist = (ListView)((AlertDialog)mDialogInterface).getListView();
playlist.setAdapter(mCurrentPlaylistAdapter); // try hacking the thing to show the listview again
Log.v("Current Playlist", "Size is: "+currentPlaylist.size()+" after setting adapter array");
playlist.setAdapter(mCurrentPlaylistAdapter);
Log.v("Playlist ListView", "Size is: "+playlist.getCount()+" after setting adapter array");

Here is the LogCat

08-08 12:10:31.127: VERBOSE/Current Playlist(4734): Size is: 12 08-08 12:10:31.127: VERBOSE/Current Playlist(4734): Size is: 11 after removing Passive by A Perfect Circle 08-08 12:10:31.127: VERBOSE/Current Playlist(4734): Size is: 11 after setting adapter array 08-08 12:10:31.127: VERBOSE/Playlist ListView(4734): Size is: 11 after setting adapter array