2 回答
TA贡献1811条经验 获得超4个赞
制作自定义的 Listview 并在元素的自定义布局中添加所有 3 个项目,假设您不想显示某个特定元素中的所有项目,然后使用属性使其不可见 visibility
TA贡献1784条经验 获得超8个赞
首先我改变了布局。所以,最后,我在 1 个布局中放置了 3 个 ListView。
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp">
<ListView
android:id="@+id/listviewResponse"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="@android:color/transparent"
android:dividerHeight="10sp"
android:paddingStart="15dp"
android:paddingEnd="15dp" />
<ListView
android:id="@+id/listviewDirect"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="@android:color/transparent"
android:dividerHeight="10sp"
android:paddingStart="15dp"
android:paddingEnd="15dp" />
<ListView
android:id="@+id/listviewOpen"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="@android:color/transparent"
android:dividerHeight="10sp"
android:paddingStart="15dp"
android:paddingEnd="15dp" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.v4.widget.SwipeRefreshLayout>
我创建了 3 个不同的适配器并将适配器设置为 Listviews
@BindView(R.id.listviewResponse)
ListView listViewResponse;
@BindView(R.id.listviewOpen)
ListView listViewOpen;
@BindView(R.id.listviewDirect)
ListView listViewDirect;
private List<Response> responses = new ArrayList<>();
private List<OpenOrder> open_orders = new ArrayList<>();
private List<DirectOrder> direct_orders = new ArrayList<>();
RequestListResponseAdapter adapterResponse;
RequestListOpenAdapter adapterOpen;
RequestListDirectAdapter adapterDirect;
adapterResponse = new RequestListResponseAdapter(getContext(), responses);
adapterOpen = new RequestListOpenAdapter(getContext(), open_orders, openType);
adapterDirect = new RequestListDirectAdapter(getContext(), direct_orders);
listViewResponse.setAdapter(adapterResponse);
listViewDirect.setAdapter(adapterDirect);
listViewOpen.setAdapter(adapterOpen);
添加回答
举报