0

I was wondering if the firebaseUI accepts custom layouts for listview? so if i make a layoutfile and add can i populate it as shown in documents?

e.g

 private ListView mListView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Find the ListView
    mListView = (ListView) findViewById(R.id.list_view);

    /* 
     * Create a DatabaseReference to the data; works with standard DatabaseReference methods
     * like limitToLast() and etc.
     */
    DatabaseReference peopleReference = FirebaseDatabase.getInstance().getReference()
        .child("people");

    // Now set the adapter with a given layout
    mListView.setAdapter(new FirebaseListAdapter<Person>(this, Person.class,
            R.layout.**MYCUSTOMLISTVIEW**, peopleReference) {

        // Populate view as needed
        @Override
        protected void populateView(View view, Person person, int position) {
            ((TextView) view.findViewById(android.R.id.**MYCUSTOMTEXTVIEW**)).setText(person.getName());
        }
    });
}

}

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807

1 Answers1

0

Yes it does. To achieve this, you need to change this:

android.R.id.**MYCUSTOMTEXTVIEW**

with

R.id.**MYCUSTOMTEXTVIEW**

And for that you need to create a new layoout resource file named MYCUSTOMTEXTVIEW. When you are using android. it means that you are using an existing template from Android. When you are using my above code, it means that you finding by id a custom view, that you need to create yourself.

If you want to add custom views, buttons, text views and so on, you'll need to do this in your onCreateViewHolder() and then do whatever you want with them in populateView() method.

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193