开发者

How to get position of the element of arrayadapter

Imagine that i have a list with a ArrayAdapter like this:

开发者_运维技巧

How to get position of the element of arrayadapter

When I long pressed Ubuntu I will go to the Context Menu

How to get position of the element of arrayadapter

Well, my question is how I can get the position in arrayadapter of Ubuntu, when I long pressed and I go to the context menu?

Thanks in advance.


Check out the Creating Menus Dev Guide section Creating a Context Menu.

public boolean onContextItemSelected(MenuItem item){
   AdapterView.AdapterContextMenuInfo contextMenuInfo = (AdapterView.AdapterContextMenuInfo)item.getMenuInfo();
   // ...
}

AdapterView.AdapterContextMenuInfo


If you are able to get the item, you can get the position using getPosition(T Item) which is detailed here and is invoked from an ArrayAdapter.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜