Listview not scrolling with a Firebase query "equalTo"

Viewed 76

My listview doesn't scroll anymore when i use equalTo on my firebase query.

When I don't use equalTo (see the query commented), my listview scrolling is ok.

final ListView list_matchs_win = findViewById(R.id.list_matchs_win);
Query queryWin = FirebaseDatabase.getInstance().getReference("Match").orderByChild("winner/name").equalTo(player.getName());
//Query queryWin = FirebaseDatabase.getInstance().getReference("Match").orderByChild("winner/name");
FirebaseListOptions<Match> optionsWin = new FirebaseListOptions.Builder<Match>()
        .setLayout(R.layout.listematchs_item)
        .setQuery(queryWin, Match.class)
        .build();
adapterWin = new FirebaseListAdapter(optionsWin) {
    @Override
    protected void populateView(View v, Object model, int position) {
        TextView date = v.findViewById(R.id.date);
        ImageView photo_winner = v.findViewById(R.id.photo_winner);
        TextView name_winner = v.findViewById(R.id.name_winner);
        ImageView photo_looser = v.findViewById(R.id.photo_looser);
        TextView name_looser = v.findViewById(R.id.name_looser);

        Match match = (Match) model;
        date.setText(match.getDate());
        Picasso.get().load(match.getWinner().getPhoto()).into(photo_winner);
        name_winner.setText(match.getWinner().getName());
        Picasso.get().load(match.getLooser().getPhoto()).into(photo_looser);
        name_looser.setText(match.getLooser().toString());
    }
};
//list_matchs_win.setTranscriptMode(ListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);
//list_matchs_win.setScrollY(adapterWin.getCount()-1);
list_matchs_win.setAdapter(adapterWin);

My db :

My db :

Screen :

screen

Any idea ?

1 Answers

Please set adapter inside the if part & also get existing adapter in else part and set again with get method it will be sure work.

Related