を表示する方法2つの選択肢があります。
- あなたのカードの内側のLinearLayoutを使用して、あなたのカードの内側RecyclerViewを使用することができますImageViewの
- を含むcustomLayoutを膨らませることができます。あなたは、既存の内部で別のRecyclerViewを使用することができます
- オプション2を説明
。
cardView - 親recyclerViewため
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ViewAllLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:orientation="vertical"
android:paddingBottom="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
.
.
.
.
<android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:paddingTop="4dp"/>
.
.
.
</LinearLayout>
</android.support.v7.widget.CardView>
ViewHolderは次のようなものに変更されます。
class MyViewHolder2 extends RecyclerView.ViewHolder {
RecyclerView recyclerView;
MyHorizontalAdapter horizontalAdapter;
......//rest of objects
.....
public MyViewHolder2(View itemView) {
super(itemView);
recyclerView = (RecyclerView) itemView.findViewById(R.id.recyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false));
horizontalAdapter = new MyHorizontalAdapter(context);
recyclerView.setAdapter(horizontalAdapter);
recyclerView.setNestedScrollingEnabled(false);
.....//rest of initialization codes
.....
.....
}
public void bind(JSONObject object) throws JSONException {
horizontalAdapter.setHorizontalData(object.getJSONArray("phone"));
........//rest of bind data
.......
.......
}
DONOTはライン
recyclerView.setNestedScrollingEnabled(false);
これは、垂直スクロールを傍受する水平recyclerViewを禁止し忘れます。
HorizontalAdapterでは、通常のRecyclerViewアダプタと同じように使用します。イメージを読み込んでいるので、PicassoやGlideのようなライブラリを使うことができます。
funtion-
public void setHorizontalData(JSONArray data){
....
notifyDataSetChanged();
}
私はあなたが複数のイメージのために、すべての内部ロジックを処理する必要があり、そのためのカスタムレイアウトを作成するべきだと思います。 –