@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(true); adapter = new PlaylistAdapter(getActivity()); dbHelper = DatabaseHelper.getInstance(getActivity()); List<Playlist> playlists = dbHelper.getAllPlaylist(); for (int i = 0; i < playlists.size(); i++) { adapter.add(playlists.get(i)); } setListAdapter(adapter); ((MainActivity) getActivity()).setActionBarTitle(PLAYLIST_FRAGMENT_TITLE); }
public void addPlaylist(Playlist playlist) { adapter.add(playlist); adapter.notifyDataSetChanged(); }
@Override public void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); callback.onPlaylistSelected((Playlist) adapter.getItem(position)); }