I have a LisView with several elements. I connected OnItemClickListener to this (as an inner class), for example:
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(ShoppingListApp02Activity.this, "List item selected:" +
items.get(position).getId(), Toast.LENGTH_LONG).show();
}
});
As you can see, when you select entriy, it displays the object elements of this record, in this example the object identifier is Item Item (not the list identifier, but the object identifier specified when creating the ArrayList elements). This works well and allows me to do whatever I want with the selected elements.
Now I also want to listen to the long-click listener, which will open the context menu for the selected ListView. How should I do it? I was able to connect the onCreateContextMenu listener to the ListView, but I do not see how I can get the ArrayList elements, how using onItemClickListener?
Here is what I have:
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
menu.add(0, v.getId(), 0, "Something");
menu.add(0, v.getId(), 0, "Something else");
}
OnCreateConextMenu , OnItemClickListener, ArrayList, , OnItemClickListener?
user1341676