Android Firebaseui未检索到所有数据

时间:2016-04-21 15:00:05

标签: android listview firebase firebase-realtime-database firebaseui

我在我的应用上执行了一项功能,用户可以在其中发布便笺。我是用firebase做的。但是,我使用FirebaseUI将firebase中的数据绑定到listview。我使用FirebaseListAdapter函数从firebase获取数据并在listview中填充它。

我意识到它没有检索到应该检索的所有数据。它只返回一个项目。自从我正确地遵循教程后,我不确定是什么问题。

以下是使用FirebaseUI函数填充列表视图的函数:

 public void setNoteListData(String locationKey){
    String accessPoint = FirebaseHelper.LocationNotesUrl + locationKey;
    firebaseNoteRef  = new Firebase(accessPoint);

    noteAdapter = new FirebaseListAdapter<Note>(MainActivity.this, Note.class, R.layout.view_notelist, firebaseNoteRef) {
        @Override
        protected void populateView(View vi, Note note, int position) {

            Log.v("Discoverify", "Position: " + position );

            ((TextView) vi.findViewById(R.id.note_username)).setText(note.getUsername());
           new DownloadImageTask(((ImageView)vi.findViewById(R.id.note_avatar))).execute(note.getProfileImage());
            ((TextView)vi.findViewById(R.id.note_text)).setText(note.getNoteText());

        }
    };
    noteList.setAdapter(noteAdapter);
    UtilsDiscoverify.setListViewHeightBasedOnChildren(noteList);
}

我注意到它只会继续返回位置0并且它会继续返回相同的位置大约五次。

请帮助,为什么会发生这种情况以及如何解决这个问题,我们将不胜感激。

编辑:

这是JSON结构:

{
  "459e0617-2355-495f-a939-76f49db991ae-07032016030827" : {
    "-KFrMApikRhycsaUv0Ja" : {
      "noteText" : "What a really great house you have Reggie :3",
      "profileImage" : "https://scontent.xx.fbcdn.net/hprofile-xat1/v/t1.0-1/p100x100/12933044_1723753131230562_1603099123146527101_n.jpg?oh=c20c1b07ee3ced68d66740c2d0568d3c&oe=5771FFA9",
      "time" : 1461217704,
      "username" : "prodoxx"
    },
    "-KFrNoXFtvBnOY0w8G6Y" : {
      "noteText" : "This is another awesome note.",
      "profileImage" : "https://scontent.xx.fbcdn.net/hprofile-xat1/v/t1.0-1/p100x100/12933044_1723753131230562_1603099123146527101_n.jpg?oh=c20c1b07ee3ced68d66740c2d0568d3c&oe=5771FFA9",
      "time" : 1461218133,
      "username" : "prodoxx"
    }
  }
}

Firebase参考应检索&#34; 459e0617-2355-495f-a939-76f49db991ae-07032016030827&#34;的所有对象。但是,它只返回第一个对象。

这是Android Log as text:

04-21 08:46:39.014 21496-21496/com.example.rescobar.discoverify V/Discoverify: Postiion: 0 & text: What a really great house you have Reggie :3
04-21 08:46:39.015 21496-21496/com.example.rescobar.discoverify V/Discoverify: Postiion: 0 & text: What a really great house you have Reggie :3
04-21 08:56:09.821 21496-21511/com.example.rescobar.discoverify W/art: Suspending all threads took: 12.941ms
04-21 09:00:23.127 21496-21511/com.example.rescobar.discoverify I/art: Debugger is no longer active
04-21 09:02:04.221 21496-21511/com.example.rescobar.discoverify W/art: Suspending all threads took: 18.559ms
04-21 09:08:09.609 21496-21511/com.example.rescobar.discoverify W/art: Suspending all threads took: 18.788ms
04-21 09:15:00.657 21496-21511/com.example.rescobar.discoverify W/art: Suspending all threads took: 6.901ms
04-21 09:16:24.960 21496-21511/com.example.rescobar.discoverify W/art: Suspending all threads took: 15.641ms
04-21 09:16:36.471 21496-21511/com.example.rescobar.discoverify W/art: Suspending all threads took: 11.794ms
04-21 09:18:08.206 21496-21511/com.example.rescobar.discoverify W/art: Suspending all threads took: 9.804ms
04-21 09:21:17.701 21496-21511/com.example.rescobar.discoverify W/art: Suspending all threads took: 7.376ms
04-21 09:25:07.235 21496-21511/com.example.rescobar.discoverify W/art: Suspending all threads took: 7.770ms
04-21 09:26:19.006 21496-21511/com.example.rescobar.discoverify W/art: Suspending all threads took: 69.351ms
04-21 09:29:05.828 21496-21511/com.example.rescobar.discoverify W/art: Suspending all threads took: 13.015ms
04-21 09:30:21.640 21496-21496/com.example.rescobar.discoverify V/Discoverify: Postiion: 0 & text: What a really great house you have Reggie :3
04-21 09:30:21.650 21496-21496/com.example.rescobar.discoverify V/Discoverify: Postiion: 0 & text: What a really great house you have Reggie :3
04-21 09:30:21.654 21496-21543/com.example.rescobar.discoverify I/OpenGLRenderer: Initialized EGL, version 1.4
04-21 09:30:21.727 21496-21496/com.example.rescobar.discoverify V/Discoverify: Postiion: 0 & text: What a really great house you have Reggie :3

0 个答案:

没有答案