我陷入了一种无法继续下去的境地。实际上我有一个cardViews 的RecyclerView,并且有一个适配器可以用数据填充卡片。我必须在卡片上显示一些餐馆。单击 Cardview 中的按钮时,我必须显示另一个 recyclerview,该 View 将填充包含该餐厅分支机构的 cardView。
这里我只有一个模型可以返回两种类型的数据。我不知道是否应该使用 1 个适配器和多个 viewHolders 还是 2 个适配器。我的 View 也是单一布局。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/margin_medium">
<android.support.v7.widget.CardView
android:id="@+id/recipient_card"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:elevation="20dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/receipient_card_height"
android:orientation="horizontal"
android:id="@+id/linear_layout">
<ImageView
android:id ="@+id/arrow_button"
android:layout_width="@dimen/size_info_icon"
android:layout_height="@dimen/size_info_icon"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_gravity="center" />
<com.inquirly.opinify.View.CustomTextView
android:id="@+id/business_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/label_small"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_gravity="center"
android:layout_weight="10"
android:text="JustBake"/>
<ImageView
android:id="@+id/recipient_business_logo"
android:layout_marginLeft="@dimen/margin_small"
android:layout_gravity="center"
android:layout_width="@dimen/receipient_business_logo_size"
android:layout_height="@dimen/receipient_business_logo_size"/>
<ImageView
android:id="@+id/expand_button"
android:layout_marginLeft="@dimen/margin_small"
android:layout_gravity="center"
android:padding="@dimen/margin_medium"
android:layout_width="@dimen/height_button"
android:layout_height="@dimen/height_button"
/>
</LinearLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_recipient_branch_list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:visible= "false"
android:padding="@dimen/margin_medium"/>
</RelativeLayout>
我一开始就让内部的recyclerView不可见。当用户单击主回收器的 CardView 按钮中的箭头按钮时,第二个回收器 View 应与分支列表一起出现。
最佳答案
关于android - 如何通过单击卡片 View 中的按钮来填充回收器 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32138068/