0
我开发一个Android应用程序,和我在动作条两个菜单,我为他们每个人的行动,但我只能够访问其中的一个,这是我的代码做动作栏上不同的动作
@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;
}
你有任何想法解决它吗?我真的很感激。
为什么两个'onOptionsItemSelected'?只需使用'switch case'来查看选择了哪个菜单并开始相应的活动。 –
是第一个menuitem工作,第二个不工作? –
在onOptionsItemSelected.Updating代码中使用开关。 –