Hi I have made layout with couple of ImageView and TextView elements due to reduction of code duplication. I have occurred to two problems:
- I need to update these elements inside of layout using data binding, but I don't know how can I access to them in order to update images and texts?
- The visibility of layout should be bind from VM object(default visibility is GONE) but it doesn't work. Even if I update VM setter for visibility, the layout is till visible on the screen.
The code:
included layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <LinearLayout
        android:id="@+id/details"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:background="#FF0000">
        <ImageView
            android:id="@+id/image_details"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <TextView
            android:id="@+id/text_details"
            android:text="details"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </LinearLayout>
    <LinearLayout
        android:id="@+id/favorites"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:background="#00FF00">
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <TextView
            android:text="details"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </LinearLayout>
    <LinearLayout
        android:id="@+id/record"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:background="#0000FF">
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <TextView
            android:text="details"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </LinearLayout>
    <LinearLayout
        android:id="@+id/remind_me"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:background="#FF0000">
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <TextView
            android:text="details"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </LinearLayout>
    <LinearLayout
        android:id="@+id/return_to_begin"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:background="#00FF00">
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <TextView
            android:text="details"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </LinearLayout>
</LinearLayout>
activity layout(this is a snippet, the whole xml is too large)
<include layout="@layout/manu_layout"
            android:layout_above="@+id/info"
            android:layout_alignParentRight="true"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:visibility="@{vm.infoMenu}"/>
viewModel method for visibility:
 public void setInfoMenu() {
        if(menuVisibility == View.VISIBLE){
            menuVisibility = View.GONE;
            setMediaControlView(false);
        }else {
            menuVisibility=View.VISIBLE;
            setMediaControlView(true);
        }
        notifyPropertyChanged(BR.infoMenu);
    }
    @Bindable
    public int getInfoMenu(){
        return menuVisibility;
    }
Please let me know if you need any additional code snippet.
Can you please help me to solve these problems?
Thanks,
Hogar
 
    