how to hide up button in actionbar

前端 未结 4 1980
醉酒成梦
醉酒成梦 2021-01-02 17:16

I would like to do an edit mode, in the style of the tablet gmail app. If the user presses the edit button on the actionbar, than I would like to show him/her an action view

4条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-02 17:36

    If you're on API level 14 or above and are not using ActionbarSherlock, this code in onCreateOptionsMenu will disable the up button, remove the left caret, and remove the icon:

    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setHomeButtonEnabled(false); // disable the button
        actionBar.setDisplayHomeAsUpEnabled(false); // remove the left caret
        actionBar.setDisplayShowHomeEnabled(false); // remove the icon
    }
    

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题