SearchView Firebase数据未显示在ListView中

时间:2018-01-02 16:01:13

标签: android listview firebase

我有问题,我在我的活动中实施了一个SearchView来通过电子邮件过滤用户数据,问题是我按下搜索后没有再看到重新填充的ListView,这就是我在做什么

userSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
            @Override
            public boolean onQueryTextSubmit(String inputQuery) {
                Query queryfilter = FirebaseDatabase.getInstance()
                        .getReference()
                        .child("Usuarios").child("email").startAt(inputQuery).endAt(inputQuery+"\uf8ff");;

                FirebaseListOptions<Usuarios> options = new FirebaseListOptions.Builder<Usuarios>()
                        .setQuery(queryfilter, Usuarios.class)
                        .setLayout(R.layout.item_row)
                        .build();
                adapterfilter = new FirebaseListAdapter<Usuarios>(options)  {
                    @Override
                    protected void populateView(View v, Usuarios model, int position) {
                        final TextView textName =  v.findViewById(R.id.NombreUsuario);
                        textName.setText( model.getNombre());
                        final TextView textEmail =  v.findViewById(R.id.Email);
                        textEmail.setText("Email: " + model.getEmail());
                        final TextView textPago =  v.findViewById(R.id.imgBtnPago);
                        textPago.setText(model.getPago());
                    }

                };
                mListView.setAdapter(adapterfilter);


                return true;
            }

            @Override
            public boolean onQueryTextChange(String newText) {

                return false;
            }
        });

1 个答案:

答案 0 :(得分:0)

我刚刚解决了在adapter.startListening();

中设置适配器后添加setAdapter的问题