0

Firebase Data View image

enter image description here

(Check My Database Image Above) doubt in array value to display list of child using recylerview, I am getting only one child data , Any Suggestion to implement with array Adapter ?

    DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
    DatabaseReference restaurantsRef =  rootRef.child("restaurants");
                                        rootRef.child("maxminutes");
                                        rootRef.child("minorder");
                                        rootRef.child("minquaninty");
                                        rootRef.child("imageUrl");
                                        rootRef.child("rating");
                                        rootRef.child("name");


    ValueEventListener valueEventListener = new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            ArrayList<RestaurantDetails> foodItems = new ArrayList<RestaurantDetails>();
            for(DataSnapshot ds : dataSnapshot.getChildren()) {
                RestaurantDetails restaurantDetails = ds.getValue(RestaurantDetails.class);
                Log.d("TAG", restaurantDetails.getDescription());
                Log.d("TAG", restaurantDetails.getImageUrl());
                Log.d("TAG", restaurantDetails.getMaxminutes());
                Log.d("TAG", restaurantDetails.getMinorder());
                Log.d("TAG", String.valueOf(restaurantDetails.getRating()));
                Log.d("TAG", restaurantDetails.getMinquaninty());
                Log.d("TAG", restaurantDetails.getName());
            }
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {}
    };
    restaurantsRef.addListenerForSingleValueEvent(valueEventListener);

    pd.dismiss();


    ArrayList <RestaurantDetails> ds = new ArrayList<RestaurantDetails>();
    final ShoplistItemArrayAdapter  shoplistItemArrayAdapter = new ShoplistItemArrayAdapter(shop_name_list,ds);
    final RecyclerView recyclerView = findViewById(R.id.my_recycler_view);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.setAdapter(shoplistItemArrayAdapter);


    for(int i=0; i<10; i++) {
        ds.add(new RestaurantDetails());
    }
KENdi
  • 7,576
  • 2
  • 16
  • 31
Kaliraj
  • 1
  • 3
  • U have not tried to implement recyclerView. We can solve your problem only. For implementation of recyclerView refer its docs. – Raj Jul 06 '18 at 17:45
  • **[This](https://stackoverflow.com/questions/49383687/how-can-i-retrieve-data-from-firebase-to-my-adapter/49384849)** is a recommended way in which you can retrieve data from a Firebase Realtime database and display it in a `RecyclerView` using `FirebaseRecyclerAdapter`. – Alex Mamo Jul 07 '18 at 08:53
  • Check also [this](https://stackoverflow.com/questions/48622480/showing-firebase-data-in-listview) out for using an `ArrayAdapter`. – Alex Mamo Jul 07 '18 at 08:55

0 Answers0