【发布时间】:2021-01-06 09:16:26
【问题描述】:
我正在尝试在不同的过滤器中对我的数据(产品)进行排序,例如按字母排序、按价格排序、按日期排序。
数据是从 Node 中的 firebase 实时数据库中获取的:
我已经用过 orderByChild 方法,但问题是它过滤数据而不是排序数据。
//recycelrView Setup for Product Listing
gridLayoutManager_categ = new GridLayoutManager(this, 2);
rv_categ.setLayoutManager(gridLayoutManager_categ);
rv_categ.setHasFixedSize(true);
//FirebaseRecyclerAdapter for fetching data from firebase and showing it into recylerview
databaseReference = FirebaseDatabase.getInstance().getReference().child("Products").child(rootText);
categ_options = new FirebaseRecyclerOptions.Builder<Products>().setQuery(databaseReference, Products.class).build();
categ_Adapter = new FirebaseRecyclerAdapter<Products, MyViewHolder_categAdapter>(categ_options) {
@Override
protected void onBindViewHolder(@NonNull final MyViewHolder_categAdapter Holder, int i, @NonNull final Products products) {
}
@NonNull
@Override
public MyViewHolder_categAdapter onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.product_layout,parent,false);
return new MyViewHolder_categAdapter(view);
}
};
categ_Adapter.startListening();
rv_categ.setAdapter(categ_Adapter);
}
如果在这种情况下不可能,那么请向我建议任何其他方法来展示我的产品。 (如使用任何其他数据库或方法等)
【问题讨论】:
标签: android firebase firebase-realtime-database firebaseui