Contextmenu not showing up in ListActivity
I'm using practically the same code in a different ListActivity, and it's working, but in this one it doesn't work.
This is the code for the context menu:
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
menu.setHeaderTitle("Anything");
menu.add(0, ContextMenu.NONE, 0, "Unsubscribe");
}
And this is the entire ListActivity:
public class UnwatchedEpisodesActivity extends ListActivity{
private ArrayList<Episode> episodeList = new ArrayList<Episode>();
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
displayEpisodes();
}
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
menu.setHeaderTitle("Anything");
menu.add(0, ContextMenu.NONE, 0, "Un开发者_如何学Gosubscribe");
}
@Override
protected void onResume() {
super.onResume();
}
Any ideas why this isn't working? When i long press an item, nothing happens.
In on onCreate() add this call:
registerForContextMenu(getListView());
精彩评论