I develop an android app, and I have two menus in action bar, I make an action for each of them, but I only able to access one of them, this is my code
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
Toast.makeText(this, "Studentsite News", Toast.LENGTH_LONG).show();
Intent i = new Intent(this, ssnews.class);
startActivity(i);
return true;
}
public boolean onOptionsItemSelected1(MenuItem item)
{
Toast.makeText(this, "About", Toast.LENGTH_LONG).show();
Intent i = new Intent(this, about.class);
startActivity(i);
return true;
}
Do you any idea to fix it? I would really appreciate it.
Read through this page: http://developer.android.com/guide/topics/ui/menus.html#RespondingOptionsMenu.
This section demonstrates the ideal way of using the
onOptionsItemSelectedmethod (actually, anything to do withMenus).The excerpt from the page (related to your situation):