数据绑定中未显示工具栏

淡淡的

我无法Toolbar露面。我做了一切。我对Android开发并不陌生。
我已经习惯了setSupportActionBar()
我试图调试,看看是否getSupportActionBar()不为空。而且它是空的。
不知道为什么 自从我开始使用Android DataBinding以来,我就一直在经历这种情况。

这就是我所做的一切:

binding = DataBindingUtil.setContentView(this, R.layout.activity_create);
createBinding = DataBindingUtil.setContentView(this, R.layout.content_create);

setSupportActionBar(binding.createToolbar);

if (getSupportActionBar() != null) {
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    String action = getIntent().getStringExtra("action");
    if (action != null) {
        if (action.equals("create")) {
            getSupportActionBar().setTitle(R.string.create);
        } else {
            getSupportActionBar().setTitle(R.string.update);
        }
    }
}

还有我的XML

    <?xml version="1.0" encoding="utf-8"?>
    <layout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:bind="http://schemas.android.com/apk/res-auto">

        <data>
            <import type="java.util.List"/>
            <variable
                name="customer"
                type="co.company.Create.Customer"/>
        </data>

        <android.support.design.widget.CoordinatorLayout
            xmlns:app="http://schemas.android.com/apk/res-auto"
            xmlns:tools="http://schemas.android.com/tools"
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            tools:context=".CreateActivity">

            <android.support.design.widget.AppBarLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:theme="@style/AppTheme.AppBarOverlay"
                android:background="@color/transparent">

                <android.support.v7.widget.Toolbar
                    android:id="@+id/createToolbar"
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    android:background="@color/colorPrimaryDark"
                    app:popupTheme="@style/AppTheme.PopupOverlay"
                    app:layout_scrollFlags="scroll|enterAlways" />

            </android.support.design.widget.AppBarLayout>

            <include layout="@layout/content_create"
                android:id="@+id/contentCreateHolder"
                bind:customer="@{customer}"/>

        </android.support.design.widget.CoordinatorLayout>
    </layout>
板球运动员

您确定要让内容视图只是这种布局吗?

<include layout="@layout/content_create"
    android:id="@+id/contentCreateHolder"
    bind:customer="@{customer}"/>

如果没有,请删除此行

createBinding = DataBindingUtil.setContentView(this, R.layout.content_create);

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Searchview未显示在工具栏中

来自分类Dev

图片未显示在工具栏中

来自分类Dev

工具栏未显示在 Fragment 中

来自分类Dev

工具栏和操作栏未显示在活动中

来自分类Dev

标题等未显示在Android工具栏中

来自分类Dev

CKEDITOR:我的工具栏中未显示某些图标

来自分类Dev

android-工具栏未显示在活动中

来自分类Dev

工具栏未显示在android应用程序中

来自分类Dev

工具栏未显示在Xamarin.Android中

来自分类Dev

在 Rails 中,tinymce 的工具栏未显示

来自分类Dev

Android工具栏菜单未显示

来自分类Dev

日历未显示在工具栏上

来自分类Dev

日历未显示在工具栏上

来自分类Dev

工具栏图标未显示

来自分类Dev

工具栏显示在导航栏中

来自分类Dev

隐藏的工具栏中的绑定错误

来自分类Dev

工具栏中的文本未居中

来自分类Dev

在下面的Lollipop版本中未显示操作栏/工具栏

来自分类Dev

在Android工具栏中显示图标

来自分类Dev

在Android工具栏中显示图标

来自分类Dev

工具栏未在iOS中显示

来自分类Dev

片段未显示在 Mainactivity 中,在我的活动片段中,仅在单击工具栏时显示

来自分类Dev

带工具栏的AppCompatActivity:菜单项未显示在工具栏上

来自分类Dev

activity.setSupportActionBar(工具栏)未显示工具栏

来自分类Dev

AG Grid React Chart工具栏未显示图表工具栏

来自分类Dev

activity.setSupportActionBar(工具栏)未显示工具栏

来自分类Dev

折叠工具栏和ImageView-工具栏未显示

来自分类Dev

工具栏未与Google地图一起显示在片段中

来自分类Dev

使用Android 5.0工具栏小部件的ActionBarActivity中未显示片段