Android context menu on async filled listview
I have a listview which is filled by AsyncTask and I am trying to create a context menu....
@Override
public void onCreateContextMenu(ContextMenu menu,
View v,
ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
AdapterContextMenuInfo info = (AdapterConte开发者_运维问答xtMenuInfo) menuInfo;
int position = info.position;
ChannelShowItem myItem = (ChannelShowItem) aa.getItem(position);
menu.setHeaderTitle("TEST");
menu.add(0, 1, Menu.NONE, R.string.remove_item);
}
I can run the app, but context menu is never created... On the other hand I tried to use the same code on listview which isn't filled by a AsyncTask and it worked OK...
I believe that I have to create context menu when data is filled, but I don't know how... Thanks for you answer!
Try overriding onPrepareContextMenu
, this method is called every time the context menu is opening. Hope this helps.
精彩评论