У меня есть ящик для навигации, который использует RecyclerView
макет. В то же время моя основная страница также использует макет RecyclerView
. Как управлять им оптимально?Могу ли я использовать ту же структуру макета (как контейнер) для отображения DrawerLayout и RecyclerView?
Это мой activity_main.xml
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--Toolbar-->
<include
android:id="@+id/toolbar_actionbar"
layout="@layout/toolbar_default"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<!-- A RecyclerView with some commonly used attributes -->
<android.support.v7.widget.RecyclerView
android:id="@+id/my_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:baselineAlignBottom="true"
android:layout_marginBottom="12dp"
android:src="@mipmap/ic_action_good" />
<!--Mulai layout drawer-->
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/toolbar_actionbar">
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true">
</FrameLayout>
<!--Fragment Drawer-->
<fragment
android:id="@+id/fragment_drawer"
android:name="com.mundane.hortipedia.NavigationDrawerFragment"
android:layout_width="@dimen/navigation_drawer_width"
android:layout_height="match_parent"
android:layout_gravity="start"
app:layout="@layout/fragment_navigation_drawer" />
</android.support.v4.widget.DrawerLayout>
Я просто хочу, чтобы принести мои данные из базы данных SQLite и показать их R.id.my_recycler_view. Но это не сработает.
http://prntscr.com/6y9wxk << мой макет схемы – eto
я думаю андроид принципы говорит, что drawerlayout должен быть корневой контейнер вашего XML. см. Это https://developer.android.com/training/implementing-navigation/nav-drawer.html – Shivansh
Хорошо. поэтому разрешено помещать Recyclerview (my_recycler_view) внутри FrameLayout (контейнер), или мне нужно создать новый фрагмент для my_recycler_view, а затем заменить контейнер. что лучше? – eto