2017-07-29 12 views
1

当用户通过选择下拉菜单过滤数据时如何更新我的Firebase列表适配器。菜单包含字符串值,我的代码如下:当用户通过选择下拉菜单过滤数据时更新Firebase列表适配器

FirebaseListAdapter<blood> adapter=new FirebaseListAdapter<blood>(this, blood.class, R.layout.blod,mref) { 

     @Override 
     protected void populateView(View v, blood model, int position) 
     { 
      final String pskey=getRef(position).getKey(); 
      TextView name_,groiup; 
      ImageView Pic; 
      groiup=(TextView)v.findViewById(R.id.bldgrp); 
      name_=(TextView)v.findViewById(R.id.name1); 
      Pic=(ImageView)v.findViewById(R.id.pic); 
      name_.setText(model.getName()); 
      groiup.setText(model.getBlodgrp()); 
} 
+0

在创建FirebaseListAdapter后,您无法更改其查询。您必须创建一个新的适配器并将其与视图绑定。请参阅https://stackoverflow.com/questions/40919636/how-to-update-a-firebaserecycleradapters-query/40923600#40923600 –

+0

@FrankvanPuffelen如何绑定新的适配器,因为我使用的是Firebase列表适配器.firebase团队应该将脱机过滤器或搜索机制firebase名单adapter.or否则没有办法使用它.. – Pritz10

回答

0

创建FirebaseListAdapter后,无法更改它,因为Firebase中的所有查询都是immutable

因为FirebaseUI中存在的适配器事实上代表了它自身的数据结构,所以Firebase创建者未添加允许您更改给定适配器的查询的选项。

请注意,当创建一个新的查询时,还会创建一个新的适配器。所以,作为一个结论,要解决你的问题,你只需要创建一个新的适配器。

希望它有帮助。

相关问题