开发者

Android context menu on async filled listview

开发者 https://www.devze.com 2023-03-11 04:11 出处:网络
I have a listview which is filled by AsyncTask and I am trying to create a context menu.... @Override public void onCreateContextMenu(ContextMenu menu,

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.

0

精彩评论

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