0

I have 2 recyclerview. I want to add different types of book images to different lines in the horizontal plane. But when I add a book, it is added to both of recyclerview. Where's my mistake?

for loop:

for (DataSnapshot ds : dataSnapshot.getChildren()) {
                        HashMap<String, String> hashMap = (HashMap<String, String>) ds.getValue();

                        mBaslik.add(hashMap.get("baslik"));
                        mFotoUrl.add(hashMap.get("downloadurl"));

                        if(hashMap.get("baslik").equals("Roman")){
                            initRecyclerView();
                        }
                        else if(hashMap.get("baslik").equals("Hikaye")){
                            initRecyclerView2();

                        }

                    }
Al Foиce ѫ
  • 4,195
  • 12
  • 39
  • 49
Enes
  • 41
  • 1
  • 10

1 Answers1

1

hashMap.get("baslik") result is null, The equals method belongs to java.lang.String

you can:

"Roman".equals(hashMap.get("baslik"))
ZLRab
  • 41
  • 5
  • It doesn't work exactly right. When I added two books, it added the novel to the first recyclerview. Secondly I added the story, this time added two books to two recyclerview. – Enes Aug 29 '19 at 08:36
  • @Old Schooled , How can we fix this issue? – Enes Aug 29 '19 at 08:45
  • This is just a solution to your "java.lang.NullPointerException" problem. – ZLRab Aug 30 '19 at 09:43
  • How can I edit this question to it does not dublicate question? – Enes Aug 31 '19 at 12:14