Amit0191
Amit0191

Reputation: 109

FirebaseRecyclerAdapter only loads 1 item

JSON

{     
"Country" : 
 {
"Cabana" : "Sydney",
"Pub" : "China",
"SkyGarden" : "Indonesia",
"Tito" : "Vietnam"
 }
}

Main Activity Code.

 mDatabaseReference=FirebaseDatabase.getInstance().getReference().child("Country");
    recyclerView=(RecyclerView)findViewById(R.id.recyclerView);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    FirebaseRecyclerAdapter<String, ViewHolder>adapter= new          FirebaseRecyclerAdapter<String, ViewHolder>(String.class,R.layout.xyz,ViewHolder.class,mDatabaseReference){

        @Override
        protected void populateViewHolder(ViewHolder viewHolder, String model, int position) {
            viewHolder.Name.setText("Name + "+model);
            // viewHolder.Serial.setText(String.valueOf(model.Serial));

        }
    };
    recyclerView.setAdapter(adapter);

The recycler View shows only 1 item. Name + Australia. How can I load more items?

How to Retrieve a List object from the firebase in android

I have gone through this post and even the Android chat App but I couldn't really understand it.

Upvotes: 0

Views: 939

Answers (1)

Gaket
Gaket

Reputation: 6829

There are to common problems: you can use incorrect height of row elements and you can import some project where the Recycler view worked horyzontally. To check for both of these problems, you can:

  1. Try swiping up/down (then you will see next element on next screen, because it will take the whole screen). In this case, you R.layout.xyz probably has root view with android:layout_height="match_parent" and you should change it to android:layout_height="wrap_content"

  2. Try swiping left/right (probably you will see next element on the left/right of current). Check that in your layout you haven't specified android:orientation="horizontal" for your RecyclerView.

Upvotes: 4

Related Questions