androidsettitle方法_在Android应用程序Toolbar.setTitle方法没有任何效果 – 应用程序名称显示为标题...

我试图创建简单的应用程序使用android-support-v7:21库。

代码段:

mainActivity.java

public class MainActivity extends ActionBarActivity {

Toolbar mActionBarToolbar;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

mActionBarToolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);

mActionBarToolbar.setTitle("My title");

setSupportActionBar(mActionBarToolbar);

}

activity_main.xml

xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:fitsSystemWindows="true"

android:orientation="vertical">

android:id="@+id/toolbar_actionbar"

android:background="@null"

android:layout_width="match_parent"

android:layout_height="?actionBarSize"

android:fitsSystemWindows="true" />

但显示工具栏%应用程序名称%而不是“我的标题”。

看起来像setTitle方法没有效果。

我想显示“我的标题”。

UPD:

之前,styles.xml是:

false

所以,我认为actionbar没有使用。

我添加NoActionBar到样式parent:

false

但问题没有解决。

任何帮助是非常感激。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值