0
名前、年齢、性別、誕生日など、FireBase
から取得したユーザーデータをいくつかリストしたいと思います。 FireBase
リスナーがあり、リストがデータベースが変更されるたびに更新する必要があります。Firebaseのカスタムリストビューアアダプタ
これは、私はこれは私が私があまりにもデータベースからリストとイメージしたい可能であれば
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/textNameList"
android:textSize="25dp"
android:textAlignment="textStart"
android:text="Name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:layout_margin="10dp"/>
<TextView
android:id="@+id/textAgeList"
android:textSize="15dp"
android:textAlignment="textStart"
android:text="Age"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:layout_margin="10dp"/>
<TextView
android:id="@+id/textBirthdayList"
android:textSize="15dp"
android:textAlignment="textStart"
android:text="Birthday"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:layout_margin="10dp"/>
<TextView
android:id="@+id/textGenderList"
android:textSize="15dp"
android:textAlignment="textStart"
android:text="gender"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:layout_margin="10dp"/>
</RelativeLayout>
を一覧表示するレイアウトですアダプター
private void list(String Name){
final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mUser);
mListView.setAdapter(arrayAdapter);
mUser.add(Name,Age,Gender,Birthday);
arrayAdapter.notifyDataSetChanged();
}
にデータを送信される方法です。
使用addValueEventのLISTNERそれは、すべての変更は、そのノード 'ref.addValueEventListener(新しいValueEventListenerに起こる耳を傾けます(){} ' –
ありがとうございますが、問題はListViewアダプタでデータを表示することです –
この最終的なArrayAdapterを初期化する必要がありますarrayAdapter = new ArrayAdapter <>(this android.R.layout.simple_list_item_1、mUser); mListView.setAdapter(arrayAdapter); '(名前、年齢、性別、誕生日); 次に 'arrayAdapter.notifyDataSetChanged();'を設定します –