如何在Firestore中提取包含地图的数组列表

时间:2019-10-30 14:23:55

标签: java android google-cloud-firestore

我正在开发一个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]

0 个答案:

没有答案