开发者

contextmenu for particular line in a multi-line view listview

I have a listview with each item in the list having 2 lines .I want to create a context menu for it such that the header of the context menu should be the text in the first line of the selected item.How to achieve this.Here the name "dfsflk" was hardcoded.I want the program to identify the selected item and display the name as the title.

@Override     
  public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) 
  {  
      super.onCreateContextMenu(menu, v, menuInfo);
      MenuInflater inflater = getMenuInflater();         
      inflater.inflate(R.m开发者_JAVA技巧enu.contextmenu, menu);
      menu.setHeaderTitle( "dfsdlk");
  }


Your question is not clear enough. Can you try to give us more info what do you want to do.

if you want to set header of context menu you can do this by calling "setHeaderTitle("some title")" on onCreateContextMenu method. Like this:

@Override
    public void onCreateContextMenu(ContextMenu menu, View v,
            ContextMenuInfo menuInfo) {
        super.onCreateContextMenu(menu, v, menuInfo);
        MenuInflater inflater = getMenuInflater();
        AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
        ProjectUser selected = projectUserList.get(info.position);
        menu.setHeaderTitle(selected.Name);
        inflater.inflate(R.menu.project_users_contextmenu, menu);

    }
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜