【问题标题】:How to change the toolbar's title in android app?如何在android应用程序中更改工具栏的标题?
【发布时间】:2017-05-09 07:15:02
【问题描述】:

我的 android 应用程序有一个工具栏,我想更改它的标题。我使用了 toolbar.setTitle() 但它不起作用...请帮助。我该怎么办?我试过 getSupportActionBar().setTitle() 但它不起作用。

【问题讨论】:

标签: java android android-toolbar


【解决方案1】:

尝试在onCreate()方法中使用this.setTitle(title);

【讨论】:

    【解决方案2】:

    使用以下代码设置标题

     Toolbar   mActionBarToolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);            
    setSupportActionBar(mActionBarToolbar);
    getSupportActionBar().setTitle("My title");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多