我在学生与老师的私人信使应用程序中使用火力地堡的工作,我可以这样根中插入数据: 火力地堡参考查询对根
的用户名是从MySQL数据库retrived,所以我只是只需要进行查询。我想只获取ListView中的数据,其中chatID等于我生成的ID。我在很多地方搜索过,如here,但无法使DatabaseReference正常工作。这里是我的代码:
private void displayStudentChatMessages() {
listofMessages = (ListView) findViewById(R.id.list_msg);
adapter = new FirebaseListAdapter<BubbleMessageStudent>(this, BubbleMessageStudent.class, R.layout.item_chat_right, FirebaseDatabase.getInstance().getReference()) {
@Override
protected void populateView(View v, BubbleMessageStudent model, int position) {
TextView studentUsername = (TextView) v.findViewById(R.id.message_user_sender);
TextView studentMessage = (TextView) v.findViewById(R.id.message_user);
TextView studentSentDate = (TextView) v.findViewById(R.id.message_usertime);
studentUsername.setText(model.getStudentUsername());
studentMessage.setText(model.getStudentMessage());
studentSentDate.setText(android.text.format.DateFormat.format("yyyy-MM-dd%n(HH:mm:ss)", model.getStudentMessageTime()));
}
};
listofMessages.setAdapter(adapter);
listofMessages.setTranscriptMode(ListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);
}
你为什么不给'getReference()'提供参数? –
但是你怎么能得到根作为参考? – DeluxeD
你的错误究竟是什么? 'getReference(“chatapp-autosiskola”)'就是我的意思,但这可能并不是必需的 –