我有一個水平RecyclerView
在ScrollView
內但沒有任何適配器方法正在觸發。臥式RecyclerView裏面ScrollView不充氣 - Android
這是我的片段與ScrollView
:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:background="@color/white"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/selector"
android:layout_width="match_parent"
android:layout_height="100dp"
android:id="@+id/selector"/>
.....
.....
</RelativeLayout>
</ScrollView>
這是我selector.xml佈局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="100dp"
android:background="@color/green">
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_kids"
android:layout_width="match_parent"
android:layout_height="100dp" />
</LinearLayout>
這裏我設置適配器的RecyclerView
:
selectorAdapter = new selectorAdapter(activity, kids);
rv_items.setLayoutManager(new LinearLayoutManager(activity, LinearLayoutManager.HORIZONTAL, false));
rv_items.setAdapter(selectorAdapter);
selectorAdapter.notifyDataSetChanged();
事情是,我已經設置到選擇器的綠色背景顯示,但沒有的適配器方法被觸發並且RecyclerView
不會膨脹。 我能做些什麼不同?
使用嵌套的滾動視圖 –
移動setadapter – Nithinlal
@Nithinlal嘿,這就是它是之前並沒有工作,即使隨後的setlayoutmanager線之上,所以我試過在下面移動它只是爲了嘗試。 – Mallika