文档显示在单独的布局中,而不是显示在一个布局中?

时间:2019-08-06 11:23:24

标签: java android firebase google-cloud-firestore

我正在做一个Android应用程序,当我使用意图时,我没有从子集合中获取所有文档。

每个集合都有一个文档和一个子集合,因此我在每个单击的项目上创建了一个侦听器,因此当用户单击该项目时,它应该显示子集合内的所有文档,并且代码应执行相同的任务,但是我不知道为什么它只显示子集合中的一个文档,我搜寻了是否还有另一种传递数据的方法,但是我发现意图是最好的。

adapter.setOnItemClickListener(new MarketAdapterRecyclerView.OnItemClickListener() {
            @Override
            public void onItemClick(DocumentSnapshot documentSnapshot, int position) {


                CollectionReference path = documentSnapshot.getReference().collection("ShoppingItems");

                path.addSnapshotListener(new EventListener<QuerySnapshot>() {
                    @Override
                    public void onEvent(@Nullable QuerySnapshot queryDocumentSnapshots, @Nullable FirebaseFirestoreException e) {

                        if (e != null) {
                            return;
                        }

                        for (DocumentChange dc : queryDocumentSnapshots.getDocumentChanges()) {

                            if (dc.getType() == DocumentChange.Type.ADDED) {

                                Item item = dc.getDocument().toObject(Item.class);
                                Intent intent = new Intent (shoppingActivity.this, ItemMarkerActivity.class);
                                intent.putExtra("keyName", item);
                                startActivity(intent);


                            }

                        }

                    }
                });

Here's the another activity that receives the intent

Here's database structure

Here's the manifest

0 个答案:

没有答案