[英]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.