Add a button to the top right of action bar

前端 未结 2 503
时光取名叫无心
时光取名叫无心 2021-02-02 10:30

Is there a way I can add a button to the top right of my ActionBar, like where the default settings Button is? I removed the settings Button

2条回答
  •  盖世英雄少女心
    2021-02-02 11:21

    This might be easier, however I use a toolbar instead:

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch(item.getItemId()) {
            case R.id.action_name:
                //your code
                break;
        }
        return super.onOptionsItemSelected(item);
    }
    

提交回复
热议问题