1

我正在我的应用程序上做一个功能,用户可以在其中发布笔记。我正在使用firebase进行此操作。但是,我使用 FirebaseUI 将 firebase 中的数据绑定到列表视图。我正在使用 FirebaseListAdapter 函数从 firebase 获取数据并将其填充到列表视图中。

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

这是假设使用 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 引用应该检索“459e0617-2355-495f-a939-76f49db991ae-07032016030827”的所有对象,但是它只返回第一个对象。

这是作为文本的 Android 日志:

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
4

0 回答 0