我想从Firebase列表和子列表导入。 Firebase数据库看起来像这样:
List_1
sublist_1 name
sublist_2 data
sublist_3 age
sublits 4 Location
List_2
sublist_1 name
sublist_2 data
sublist_3 age
sublits 4 Location
List_3
sublist_1 name
sublist_2 data
sublist_3 age
sublits 4 Location
这就是我现在在Android Studio中所拥有的:
@Override
protected void onStart() {
super.onStart();
final ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mCursa);
mListViewCurse.setAdapter(adapter);
Firebase curseRef = mRootRef.child("List_1");
curseRef.addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
String message = dataSnapshot.getValue(String.class);
Log.v("E_CHILD_ADDED", message);
mCursa.add(message);
adapter.notifyDataSetChanged();
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
String message = dataSnapshot.getValue(String.class);
Log.v("E_CHILD_CHANGED", message);
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
String message = dataSnapshot.getValue(String.class);
Log.v("E_CHILD_REMOVED", message);
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onCancelled(FirebaseError firebaseError) {
}
});
}
这是输出:
有人可以告诉我需要添加的内容,以便在Android应用中查看所有列表吗?