微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

java-Listview不使用Firebase查询“ equalTo”滚动

当我在firebase查询上使用equalTo时,我的列表视图不再滚动.

当我不使用equalTo时(请参阅注释的查询),我的列表视图滚动就可以了.

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);

我的数据库

屏幕:

任何想法 ?

最佳答案
请在if部分&中设置适配器.也可以在else部分中获取现有适配器,并再次使用get方法进行设置,以确保可以正常工作.

原文地址:https://www.jb51.cc/android/531302.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐