How to get position of the element of arrayadapter
Imagine that i have a list with a ArrayAdapter like this:
开发者_运维技巧When I long pressed Ubuntu I will go to the Context Menu
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.
精彩评论