How to click option menu open new activity?
I am can just click option menu and show message but can't click optin menu and open new activity
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Neeraj KumarPosted Jul 3, 2015, 2:18 PM
Manoj BhoirPosted Jun 7, 2015, 12:19 AM
You have to override
onOptionsItemSelectedmethod in your Activity, which is called when user clicks on the item in Options menu. In the method you can check what item has been clicked.public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
case R.id.menu_item1:
Intent intent = new Intent(this, ActivityForItemOne.class);
this.startActivity(intent);
break;
case R.id.menu_item2:
// another startActivity, this is for item with id "menu_item2"
break;
default:
return super.onOptionsItemSelected(item);
}
return true;
}