我在活动中创建了菜单。我可以看到2.X版本的菜单,但我无法看到4.x版Android手机中的菜单我做错了什么。我试着吼一声 listview as action overflow in sherlock actionbar, ActionBarSherlock, ActionBar and Native menu, how to proceed?, https://stackoverflow.com/questions/17930664/unable-to-show-the-3-dotted-menu-in-overflow-sherlockactionbar,https://stackoverflow.com/questions/9286822/how-to-force-use-of-overflow-menu-on-devices-with-menu-button/11438245#11438245
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// TODO Auto-generated method stub
android.view.MenuInflater inflater = getMenuInflater();
getSherlock().getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
switch (item.getItemId()) {
case R.id.close_tab:
TabHost tabHost = AllFriendList.self.getTabHost();
int position = tabHost.getCurrentTab();
Log.d("Position",Integer.toString(position));
Log.d("Z val in delete()",Integer.toString(z));
if(position >0)
{
tabHost.getCurrentTabView().setVisibility(View.GONE);
tabHost.setCurrentTab(position+1);
z-=1;
if(z<0)
z=0;
}
else if(position == 0)
{
tabHost.getCurrentTabView().setVisibility(View.GONE);
tabHost.setCurrentTab(position+1);
z=0;
}
else if(position == z)
{
tabHost.getCurrentTabView().setVisibility(View.GONE);
tabHost.setCurrentTab(z-1);
Log.d("Z value in final","lol");
Log.d("Pos",Integer.toString(position));
Log.d("z pos",Integer.toString(z));
}
TabActivity parent = (TabActivity) getParent();
TabHost tabhost = parent.getTabHost();
tabhost.setCurrentTab(z+1);
return true;
default:
return true;
}
}
任何人都可以帮助我 感谢
答案 0 :(得分:0)
在switch语句中添加break。