【发布时间】:2017-04-19 01:30:16
【问题描述】:
我正在使用 FirebaseListAdapter 并尝试从我的 Firebase 数据库中获取打开的聊天室列表,结构非常简单:
这是我查询时得到的:
{-KY99IS2mLzayD4HDyd6={location={...}, posts={....} , title="chatname"}
我想要实现的是在没有 ID 部分的情况下获取数据,因此它适合我的对象构建器,类似这样:
{location={...}, posts={....} , title="chatname"}
我知道ChildEventListener 可以做到这一点,但我没有选择将它与 FirebaseListAdapter 一起使用,所以我希望有另一种方法可以做到这一点。
我的代码是:
FirebaseListAdapter<ChatRoom> firebaseListAdapter = new FirebaseListAdapter<ChatRoom>(this,ChatRoom.class,R.layout.chatslist_row,myRef3) {
@Override
protected void populateView(View v, ChatRoom chatRoom, int position) {
System.out.println(chatRoom.title);
}
};
但是因为关键部分不行,不能使用我的ChatRoom类对象生成器。
谢谢!
【问题讨论】:
-
@JohnO'Reilly 其实不,不一样
-
我认为的相似之处是存在嵌套数据,您必须执行单独的查询才能检索......重新阅读您的问题我不清楚是否是这种情况您遇到的问题?
标签: android listview firebase firebase-realtime-database firebaseui