0

我在我的活动中创建了菜单。我可以看到 2.X 版本的菜单,但我无法在 4.x 版本的安卓手机中看到菜单我做错了什么。我在 sherlock actionbar、 ActionBarSherlock、ActionBar 和 Native 菜单中尝试了下面的事情 listview 作为动作溢出,如何进行?, https://stackoverflow.com/questions/17930664/unable-to-show-the-3-dotted-menu-in-overflow-sherlockactionbar, https://stackoverflow.com/questions/9286822/how-to-force -使用溢出菜单在设备上带有菜单按钮/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;
    }   
}

谁能帮帮我谢谢

4

1 回答 1

0

在你的 switch 语句中添加 break。

于 2013-10-30T04:57:13.657 回答