开发者

How can I get the view when a context menu is invoked

In android, I have a List Activity (subclass from ListActivity). And i want to add a context menu for 开发者_如何学Goeach item in the list view. So I overload public boolean onContextItemSelected(MenuItem item), but from that method, how can I find out the actual view that user has clicked to invoke the context menu? The view of an item in the listview?

Thank you.


michael,

in onContextItemSelected() you want to call

AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();

then the item that was clicked on will be stored in info.id

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜