开发者

Contextmenu not showing up in ListActivity

开发者 https://www.devze.com 2023-03-29 04:19 出处:网络
I\'m using practically the same code in a different ListActivity, and it\'s working, but in this one it doesn\'t work.

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());
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号