How to add buttons like refresh and search in ToolBar in Android?

后端 未结 4 1749
情书的邮戳
情书的邮戳 2020-12-12 18:50

\"enter

I have made a ToolBar, but when I add menu items in menu.xml it always shows a

4条回答
  •  北荒
    北荒 (楼主)
    2020-12-12 19:27

    Try to do this:

    getSupportActionBar().setDisplayShowTitleEnabled(false);
    getSupportActionBar().setDisplayHomeAsUpEnabled(false);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    

    and if you made your custom toolbar (which i presume you did) then you can use the simplest way possible to do this:

    toolbarTitle = (TextView)findViewById(R.id.toolbar_title);
    toolbarSubTitle = (TextView)findViewById(R.id.toolbar_subtitle);
    toolbarTitle.setText("Title");
    toolbarSubTitle.setText("Subtitle");
    

    Same goes for any other views you put in your toolbar. Hope it helps.

提交回复
热议问题