我正在开发一个Android应用,客户端在其中下订单,并将订购的项目存储在数组列表中。我试图从列表中检索数据以显示客户订购的产品,但似乎无法通过。友善的帮助
Query query = ordersRef.document(orderID).collection("listOrders");
FirestoreRecyclerOptions<OrderProduct> options = new FirestoreRecyclerOptions.Builder<OrderProduct>()
.setQuery(query,OrderProduct.class)
.build();
FirestoreRecyclerAdapter<OrderProduct, OrderItemViewHolder> adapter= new FirestoreRecyclerAdapter<OrderProduct, OrderItemViewHolder>(options) {
@Override
protected void onBindViewHolder(@NonNull OrderItemViewHolder holder, int position, @NonNull OrderProduct model) {
holder.txtProductName.setText(model.getProductName());
holder.txtProductQuantity.setText(model.getQuantity());
holder.txtProductPrice.setText(model.getPrice());
}
@NonNull
@Override
public OrderItemViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.orders_layout, parent, false);
OrderItemViewHolder holder = new OrderItemViewHolder(view);
return holder;
}
};
ordersList.setAdapter(adapter);
adapter.startListening();
}[enter image description here][1]