hi am really struck with this question. I’m new in android world.I have a list which display info from database.(id , name and description). On click and hold operation i want to delete selected row from database. I already implemented the context menu but am not getting the id from database but returns position (0 but id from db is 1).thanx
i think i got it 🙂
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, view, menuInfo);
TextView ids = (TextView)findViewById(R.layout.list_row);
AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
int position = info.position;
int foldeiId=(Integer) adapter.getItem(position);
String fd = String.valueOf(view.getId());
// Log.w("Data id arunmr: ", foldeiId);
System.out.println(foldeiId);
menu.setHeaderTitle("Options");
menu.add(0, NEW_MENU_ITEM, foldeiId, "Delete");
menu.add(0, SAVE_MENU_ITEM, foldeiId, "Rename");
}
but any idea how to access the mentioned “foldeiId” from context menu ?
try this
You can get the foldeiId if you declare that variable outside the oncreate() method