Solution 1:

The below is implied from FirebaseUI version 3.0+

remove this:

   adapter = new FirebaseListAdapter<ChatMessage>(this,ChatMessage.class,R.layout.list_item,FirebaseDatabase.getInstance().getReference())

you need to add this:

FirebaseListOptions<ChatMessage> options =
            new FirebaseListOptions.Builder<ChatMessage>()
                    .setQuery(query, ChatMessage.class)
                     .setLayout(android.R.layout.simple_list_item_1)
                    .build();
 adapter = new FirebaseListAdapter<ChatMessage>(options){

query is the query that you make for the list adapter example:

Query query = FirebaseDatabase.getInstance().getReference().child("chats");

more information here:

Using FirebaseUI to populate a ListView