【问题标题】:Multi category filter option in androidandroid中的多类别过滤器选项
【发布时间】:2016-05-03 04:18:53
【问题描述】:

我正在构建一个安卓应用程序。我需要在哪里实现像 Flipkart Filter 菜单样式这样的选项卡列表。我在这样的 LinerLayout 中水平有两个回收器视图(带有多选选项)。我的第一个 recyclerview 将具有列表类别,并且每个类别的 onclick 第二个 recyclerview 将填充多选。我可以使用两个不同的适配器来做到这一点。

再次在第二个 recyclerview 中选择几个项目后,我将在第一个 recyclerview 中再选择一个类别,然后第二个 recyclerview 将使用新数据进行更新。但是我怎样才能保留以前的选择?

<?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:background="@color/base_background"
android:layout_height="match_parent">
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/app"
    android:text="Apply Filter"
    android:layout_margin="10dp"
    android:textSize="20sp"
    android:layout_gravity="center_horizontal"/>
<LinearLayout
    android:id="@+id/LinearLayout02"
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:layout_alignParentBottom="true">
    <Button
        android:id="@+id/Button02"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1" android:text="Clear Filters">
    </Button>
    <Button
        android:id="@+id/Button03"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Apply">
    </Button>
</LinearLayout>
<LinearLayout
    android:layout_width="fill_parent"
    android:orientation="horizontal"
    android:layout_height="fill_parent">
    <android.support.v7.widget.RecyclerView
        android:id="@+id/View01"
        android:layout_width="0dp"
        android:clipToPadding="false"
        android:layout_height="fill_parent"
        android:layout_marginRight="5dp"
        android:layout_weight="0.4"
         />
    <android.support.v7.widget.RecyclerView
        android:id="@+id/View02"
        android:layout_width="0dp"
        android:clipToPadding="false"
        android:scrollbars="vertical"
        android:layout_height="fill_parent"
        android:layout_marginRight="5dp"
        android:layout_weight="0.6"
         />
</LinearLayout>

【问题讨论】:

    标签: android android-recyclerview android-filter


    【解决方案1】:

    我认为你应该有一个数据结构来存储被选中的项目,然后在填充第二个 recyclerview 时检查你插入的项目是否在数据结构中,如果它在你的数据结构中使用 recyclerViewAdapter.setSelectedItem(recyclerViewAdapter.getItemCount() - 1) 以编程方式选择项目。

    【讨论】:

      猜你喜欢
      • 2012-07-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-30
      • 1970-01-01
      • 1970-01-01
      • 2015-02-25
      • 1970-01-01
      相关资源
      最近更新 更多