0
나는 이름, 나이, 성별 및 생일과 같은 사용자 데이터를 나열하고 싶습니다. FireBase
. FireBase
수신기가 있고 목록이 데이터베이스가 변경 될 때마다 새로 고쳐야합니다.Firebase의 사용자 정의 ListView 어댑터
이것은 내가 이것은 내가 너무 데이터베이스에서 목록 및 이미지 싶습니다 가능하면
<?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의 청취자() {}' –
고맙겠지 만 문제는 ListView 어댑터가 데이터를 보여주기 위해서 –
이 finalAdapter arrayAdapter = new ArrayAdapter <> (this android.R.layout.simple_list_item_1, mUser)를 초기화해야합니다. mListView.setAdapter (arrayAdapter); ' 바깥 쪽에서 데이터베이스의 새 값만 에 추가하면 mUser.add (이름, 나이, 성별, 생일); 목록에'arrayAdapter.notifyDataSetChanged(); '가 설정됩니다. –