Firebase列表适配器不会将数据从Firebase填充到Android设备

时间:2017-01-10 06:57:17

标签: android firebase firebase-realtime-database firebaseui

java代码

DatabaseReference database = FirebaseDatabase.getInstance().getReferenceFromUrl("https://fireapp-353b2.firebaseio.com/Users id");

FirebaseListAdapter<String> firebaselistadapter= new FirebaseListAdapter<String>(
            this,
            String.class,
            android.R.layout.simple_expandable_list_item_1,
            database
    ) {
        @Override
        protected void populateView(View v, String model, int position) {

            TextView textView= (TextView) v.findViewById(R.id.text1);
            textView.setText(model);
        }
    };
    lv.setAdapter(firebaselistadapter);

XML

 <ListView
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_centerHorizontal="true"
    android:id="@+id/lv"/>
<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/text1"/>

规则

    {
  "rules": {
    ".read": "auth == null",
    ".write": "auth == null"
  }
}

JSON
{
  "Name" : "hbhbh",
  "Users id" : {
    "I ggvf" : "ffbv",
    "ffg" : "xxzzz",
    "ghar" : "fhjbv",
    "ghvf" : "ffhbft"
  }
}

列表视图是在xml中定义的,它占据了整个屏幕,但textview只是写成临时的,因此可以在填充视图中设置。但仍然没有显示。

0 个答案:

没有答案
相关问题