Not getting data from Firebase in RecyclerView

后端 未结 1 831
灰色年华
灰色年华 2021-01-28 03:27

everyone, I was trying to make a music app, and for this, I Created a Horizontal RecyclerView in my HomeFragment and my horizontal RecyclerView

相关标签:
1条回答
  • 2021-01-28 03:34

    The problem in your code lies in the fact that the names of the fields in your TestUploads class are different than the name of the properties in your database. You have in your TestUploads class a field named songName but in your database, I see it as SongName and this is not correct. The names must match. When you are using a getter named getSongName(), Firebase is looking in the database for a field named songName and not SongName. See the lowercase s letter vs. capital letter S?

    There are two ways in which you can solve this problem. The first one would be to remove the data in your database and add it again using field names that start with lowercase, as exist in your TestUploads class.

    If you are not allowed to use the first solution, then the second approach will be to use annotations. So you should use the PropertyName annotation in front of the getters. So in your TestUploads class, a getter should look like this:

    @PropertyName("SongName")
    public String getSongName() {
        return songName;
    }
    
    0 讨论(0)
提交回复
热议问题