I want one option menu when I touch the button for 2 or 3 second in my application. Example: In the Message Application when I touch particular message for 2 to 3 second then one option menu come which show:
Delete
copy
Lock
Forward
Copy to Sim
etc. So how can I use this on my application. Can I use
onOptionsItemSelected
this method.Or something else.
Here One more thing which I want, suppose in Context Menu Five Action is there and after selecting fifth action first action will disable and only enable when I select Fourth Action. Suppose the cose is:
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
menu.setHeaderTitle("Option Menu");
menu.add(0, v.getId(), 0, "First Action");
menu.add(0, v.getId(), 0, "Second Action");
menu.add(0, v.getId(), 0, "Third Action");
menu.add(0, v.getId(), 0, "Fourth Action");
menu.add(0, v.getId(), 0, "Fifth Action");
}
now when I select Fifth Action then First Action will disable and only enable when I select Fourth Action. Please Suggest me...
FYI, the menu which you are talking about is known as Context Menu, not an Option Menu.
More detailed example is given here: http://www.stealthcopter.com/blog/2010/04/android-context-menu-example-on-long-press-gridview/
Guidelines for Menu: http://developer.android.com/guide/topics/ui/menus.html
Once you are done with example, just implement OnLongClickListener
to your button.