简体   繁体   English

如何在从 firebase android 获取的列表上按名称和价格应用过滤器

[英]How to apply filters by name and price on list fetched from firebase android

i am new to android and i am working on my Practice app in which i am using firebase realtimeDatabase.我是 android 的新手,我正在开发我的练习应用程序,我正在使用 firebase 实时数据库。 I have stored some data on the DB and i am getting it in List, which is working fine but there is some problem that i want to apply Filters on my list with Price and Name of the items present in the list.我已经在数据库上存储了一些数据,并且我在列表中获取它,这工作正常,但是有一些问题我想在我的列表中应用过滤器,其中包含列表中存在的项目的价格和名称。 I am unable to do that.我无法做到这一点。 i am using Material Chips buttons to apply filters.我正在使用 Material Chips 按钮来应用过滤器。 i tried some github topics to do this but couldn't do that.我尝试了一些 github 主题来执行此操作,但无法执行此操作。 Kindly give me some guidelines so that i can do this sorting.请给我一些指导方针,以便我可以进行这种排序。

Try something like this-试试这样的 -

String name = "Pen";
Integer price = 100;

CollectionReference productRef = firebaseFirestore.collection("products");
productRef.whereEqualTo("name", name).whereGreaterThanOrEqualTo("price",price).orderBy("name", Direction.ASCENDING).get().addOnSuccessListener(new OnSuccessListener<QuerySnapshot>() {
    @Override
    public void onSuccess(QuerySnapshot queryDocumentSnapshots) {

    }
});

for more such queries with firestore check this- https://firebase.google.com/docs/firestore/query-data/queries#java有关使用 firestore 的更多此类查询,请查看此 - https://firebase.google.com/docs/firestore/query-data/queries#java

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在从 Firebase android kotlin 获取数据时显示加载的项目 - How to display items loading while data is being fetched from Firebase android kotlin 如何在 mvvm 架构中按值对从 firebase 获取的 recyclerview 数据进行排序 - How to sort recyclerview data fetched from firebase by value in mvvm architecture 未从 firebase 获取图像 - Images are not getting fetched from firebase 如何从 android 中 firebase 的图像列表中获取单个图像 - how to get single image from list of images from firebase in android 如何使用 android searchView 从 firebase firestore 中搜索数据列表 - How to search list of data from firebase firestore using android searchView 如何将我的应用程序从 firebase 获取的数据设置到我的 bottomSheetView? (科特林) - How can I set the fetched data of my app from firebase to my bottomSheetView? (Kotlin) 如何在 spark scala dataframe 视图上应用过滤器? - How to apply filters on spark scala dataframe view? 如何使用 where 子句从 firebase 正确获取数据,并使用 flutter 从 firebase 中正确获取数据 - How to correctly fetch data from firebase using where clauses and custom filters from firebase using flutter React Native与Firebase:如何限制获取数据的次数 - React Native and Firebase: how to limit number of times data are fetched 将 Firebase 应用到 Android Studio 项目版本 Bumblebee - Apply Firebase to Android Studio Project version Bumblebee
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM