I'm using android data binding and navigation component. I have activity_member layout. This layout includes another layout:
<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/appbar" />
and in app_bar_main layout include another layout:
<include
android:id="@+id/member"
layout="@layout/content_main" />
In content_mainI want to put main host fragmnet for using navigation component:
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.constraintlayout.widget.ConstraintLayout 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"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".ui.MembersPage.MemberActivity"
tools:showIn="@layout/app_bar_main">
<fragment
android:id="@+id/my_nav_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="500dp"
app:defaultNavHost="true"
app:navGraph="@navigation/navigation"
tools:layout_editor_absoluteX="-29dp"
tools:layout_editor_absoluteY="215dp"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
This is the host fragment in navigation graph. I need to access recyclerView in java class but I can not:
binding.appbar.member.membersRecycler.setLayoutManager(new GridLayoutManager(this, 3));
and:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".MembersFragment"
>
<android.support.v7.widget.RecyclerView
android:id="@+id/membersRecycler"
android:layout_width="400dp"
android:layout_height="wrap_content" />
</FrameLayout>
How to access to nested elements in this situation like recyclerView id here?