Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

data bind view tag isn't correct on view:null #25

Open
mosentest opened this issue Apr 29, 2016 · 2 comments
Open

data bind view tag isn't correct on view:null #25

mosentest opened this issue Apr 29, 2016 · 2 comments

Comments

@mosentest
Copy link

mosentest commented Apr 29, 2016

data bind view tag isn't correct on view:null

布局文件

<data>

    <variable
        name="user"
        type="org.xxx.bean.User" />
</data>

<LinearLayout 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:background="@color/line"
    android:gravity="center"
    android:orientation="vertical"
    tools:context="org.xxx.module.invite.InviteActivity">


    <TextView
        android:id="@+id/tv_currentUserName"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="@dimen/x16"
        android:gravity="center"
        android:text="@{user.nick}"
        android:textColor="@color/black_p50" />

    <include layout="@layout/fragment_other_plus" />


</LinearLayout>

在Activity类中
@OverRide
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityInviteBinding dataBinding = DataBindingUtil.setContentView(this, R.layout.activity_invite);
User currentUser = User.getCurrentUser(getApplicationContext(), User.class);
dataBinding.setUser(currentUser);
}

@andych008
Copy link
Collaborator

andych008 commented May 23, 2016

<layout  xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">
</layout>

最外层应该用<layout>包起来,并且,namespase也在这个标签里声明。不可以写在<LinearLayout>里。

@MarsKang1
Copy link

卧槽,你的回答完美解决了我的问题,666

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants