I have a main action with a side navigation box in the action bar, indicated below (note that a lot of code was omitted for brevity) in default_screen.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="190dp"
android:background="@drawable/honeycomb"
android:orientation="vertical"
>
<android.support.design.widget.NavigationView
android:id="@+id/navigation_view"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:layout_gravity="start"
app:headerLayout="@layout/header"
app:menu="@menu/drawer"
/>
where layout / header looks like this (again, for brevity, a number of lines are omitted):
<data>
<variable name="user" type="oose2017.place2b.ClientUser"/>
</data>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{user.displayName}"
android:textSize="14sp"
android:textColor="#FFF"
android:textStyle="bold"
android:gravity="left"
android:paddingBottom="4dp"
android:id="@+id/username"
android:layout_above="@+id/email"
android:layout_alignLeft="@+id/profile_image"
android:layout_alignStart="@+id/profile_image" />
</RelativeLayout>
Where I create an instance of default_screen in the main action as follows:
setContentView(R.layout.default_screen);
How to bind data to a header? I tried several things unsuccessfully, basically:
DefaultScreenBinding binding = DataBindingUtil.setContentView(R.layout.default_screen);
What does not work. How can i do this?
source
share