私は、CoordinatorLayoutとFrameLayoutでフラグメントを作成し、他のフラグメントを埋めます。これらのフラグメントの1つにRecyclerViewが1つ含まれています。私の質問は、ファイル内にあるCoordinatorLayoutでRecyclerViewを動作させる方法です。私はFragment親としてNestedScrollViewを配置しようとしましたが、このとき、アダプタのRecyclerViewの "onBindViewHolder"がすべての要素に対して呼び出されます。コーディネーター異なるフラグメントのRecyclerViewを使用した
主なフラグメントはCoordinatorLayoutにRecyclerView
<android.support.v4.widget.NestedScrollView
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"
android:fillViewport="true"
android:background="@color/background"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.v7.widget.RecyclerView
android:id="@+id/my_list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.v4.widget.NestedScrollView>
この方法でスクロール作品と
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:background="@color/background">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:elevation="0dp"
app:layout_scrollFlags="scroll|enterAlwaysCollapsed"/>
<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/toolbar"
android:background="@color/colorTab"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="@+id/container_restaurant"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
フラグメントが含まれていますが、「onBindViewHolderは」 "ではない人たちを含め、すべての項目について呼び出されました見える "。 NestedScrollViewの代わりにLinearLayoutを配置すると、 "onBindViewHolder"は正しい方法で動作しますが、CoordinatorLayoutを使ったスクロール動作( "@ string/appbar_scrolling_view_behavior")は機能しません。
( "@文字列/ appbar_scrolling_view_behavior")スクロール動作で
FrameLayout
として親を維持してください。リサイクル機能は動作しません。そして、より多くの記憶と遅れを使用します。 – wonsuc