开发者

on longclick, contextmenu

i am having a simple cursor adapter list of (say)five items. Each item in the list contains two text views. i have also implemented contextmenu in the list on long-click action. what do i need is that, i want to get the textview values from the list to t开发者_Go百科he context-menu for further proceedings.... Thanks in advance :)


If I got your question right, and you are using ListActivity, you only need to override the onCreateContextMenu method:

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo)
{
    super.onCreateContextMenu(menu, v, menuInfo);
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
    menu.setHeaderTitle("Sample menu");
    menu.add(0, 0, 0, "First menu item");
    menu.add(0, 1, 0, "Details on " + ((TextView)info.targetView.findViewById(R.id.textview_1)).getText());
    menu.add(0, 1, 0, "More about " + ((TextView)info.targetView.findViewById(R.id.textview_2)).getText());
}

Please let me know if this is what you're looking for

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜