Mordred Mordred -4 years ago 363
Android Question

Use Firebase list adapter with Card View

I have my firebase list adapter as follows

protected void onCreate(Bundle savedInstanceState) {
mListview = (ListView) findViewById(;

mAuth = FirebaseAuth.getInstance();
//the post list shit is happening here

DatabaseReference root = FirebaseDatabase.getInstance().getReference();
FirebaseUser user = mAuth.getCurrentUser();
DatabaseReference postRef = root.child("users").child(user.getUid().toString()).child("posts");

ListAdapter adapter = new FirebaseListAdapter<PostList>(this,PostList.class,android.R.layout.simple_list_item_1,postRef) {
protected void populateView(View view, PostList postList, int i) {
TextView text = (TextView)view.findViewById(;



I have a normal xml with a list view and another xml with its card view

my problem is that i cannot find a way to relate my cardview xml file to my activity, so my list just keep showing up as a normal list,
While initializing the firebase list adapter, I found an

im not sure exactly how that works and i have googled, nothing explains definitely why i cant just say
instead. Also, please let me know if i am going about this all wrong.

Answer Source

I got the answer to this already, Just in case anyone is going through the same problem, just as Linxy clearly stated, it is better to use FirebaseRecyclerAdapter, it is a modified version of the ListAdapter.

However if you feel like you still want to use a ListAdapter, then:

  1. First note that you cannot directly edit android.R.layout.items, instead create your own layout, say you have row.xml in your layout files, use R.layout.row as your populateView() arguments and not android.R.layout.row, the latter wont find anything because those layout files are stored in your SDK folder.

  2. Please, consider the recycler adapter, its not that hard.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download