我正在尝试做菜单选项...我得到了它,但是在点击幻灯片菜单中的选项后...控件应该进入相应的页面..我试过..但它不起作用..请帮助我
switch(position){
case '0': {
startActivity(new Intent(home.this, home.class));
finish();
}
case '1':
{
startActivity(new Intent(home.this, info_values.class));
finish();
}
}
答案 0 :(得分:1)
你应该尝试这样
switch(position){
case 0:
startActivity(new Intent(home.this, home.class));
finish();
break;
case 1:
startActivity(new Intent(home.this, info_values.class));
finish();
break;
default:
break;
}
答案 1 :(得分:0)
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case 'R.id.a':
startActivity(new Intent(home.this, home.class));
case 'R.id.b':
startActivity(new Intent(home.this, info_values.class));
}
return true;
}