Android动作栏没有显示

时间:2015-06-25 13:38:07

标签: android android-actionbar

我制作了一个程序代码,我想将操作栏放在其中一个屏幕的右上角,但是,操作栏没有显示或者更糟,我甚至不能指向那个页面。我曾尝试过各种在线教授的方法,但我仍然遇到同样的问题。有人可以帮帮我吗?

这是我遇到问题的代码:

public class PlayActivity extends ActionBarActivity {

    public static final int MENU_ITEM_RESTART = Menu.FIRST;
    public static final int MENU_ITEM_CLEAR_NOTES = Menu.FIRST + 1;
    public static final int MENU_ITEM_FILL_IN_NOTES = Menu.FIRST + 2;
    public static final int MENU_ITEM_UNDO = Menu.FIRST + 3;
    public static final int MENU_ITEM_HELP = Menu.FIRST + 4;
    public static final int MENU_ITEM_SETTINGS = Menu.FIRST + 5;

    public static final int MENU_ITEM_SET_CHECKPOINT = Menu.FIRST + 6;

    public static final int MENU_ITEM_UNDO_TO_CHECKPOINT = Menu.FIRST + 7;

    private static final int DIALOG_RESTART = 1;
    private static final int DIALOG_WELL_DONE = 2;
    private static final int DIALOG_CLEAR_NOTES = 3;
    private static final int DIALOG_UNDO_TO_CHECKPOINT = 4;

    private static final int REQUEST_SETTINGS = 1;



    private IMControlPanel mIMControlPanel;
    private IMControlPanelStatePersister mIMControlPanelStatePersister;
    private IMPopup mIMPopup;
    private IMSingleNumber mIMSingleNumber;

    private boolean mShowTime = true;
    private GameTimer mGameTimer;
    private GameTimeFormat mGameTimeFormatter = new GameTimeFormat();
    private boolean mFullScreen;
    private boolean mFillInNotesEnabled = false;

    private HintsQueue mHintsQueue;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setHasOptionsMenu();



        // theme must be set before setContentView
        AndroidUtils.setThemeFromPreferences(this);

        setContentView(R.layout.play);
        mRootLayout = (ViewGroup) findViewById(R.id.root_layout);
        mTimeLabel = (TextView) findViewById(R.id.time_label);

        mHintsQueue = new HintsQueue(this);
        mGameTimer = new GameTimer();

        mGuiHandler = new Handler();


    @Override
    protected void onPause() {
        super.onPause();

        // we will save game to the database as we might not be able to get back
        mDatabase.updateSudoku(mSudokuGame);

        mGameTimer.stop();
        mIMControlPanel.pause();
        mIMControlPanelStatePersister.saveState(mIMControlPanel);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();

        mDatabase.close();
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);

        mGameTimer.stop();


    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        super.onCreateOptionsMenu(menu);
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.list_menu, menu);
        return true;
    }


    /*@Override
    public boolean onCreateOptionsMenu(Menu menu) {
        super.onCreateOptionsMenu(menu);

        menu.add(0, MENU_ITEM_UNDO, 0, R.string.undo)
                .setShortcut('1', 'u')
                .setIcon(android.R.drawable.ic_menu_revert);

        menu.add(0, MENU_ITEM_RESTART, 1, R.string.restart)
                .setShortcut('7', 'r')
                .setIcon(android.R.drawable.ic_menu_rotate);

        menu.add(0, MENU_ITEM_CLEAR_NOTES, 0, R.string.clear_all_notes)
                .setShortcut('3', 'a')
                .setIcon(android.R.drawable.ic_menu_delete);

        menu.add(0, MENU_ITEM_HELP, 1, R.string.help)
                .setShortcut('0', 'h')
                .setIcon(android.R.drawable.ic_menu_help);

        menu.add(0, MENU_ITEM_SETTINGS, 1, R.string.settings)
                .setShortcut('9', 's')
                .setIcon(android.R.drawable.ic_menu_preferences);

        menu.add(0, MENU_ITEM_SET_CHECKPOINT, 2, R.string.set_checkpoint);
        menu.add(0, MENU_ITEM_UNDO_TO_CHECKPOINT, 2, R.string.undo_to_checkpoint);

        return true;
    }

}

有没有人遇到过这个问题?任何帮助将不胜感激。

0 个答案:

没有答案