0

I tried to fetch some JSON into a RecyclerView when searching for some book, all looks fine to me, but when searching the RecyclerView doens't show up. I got this error in Logcat: E/RecyclerView: No adapter attached; skipping layout that's the only thing returning an error, but I did set the recyclerView.setAdapter(adapter);

I'm using Google Books API to search ISBN using the phone camera, and also search book titles, authors and keywords. My aim is to show matching/similar books from search inside the RecyclerView, then the user can choose which one he wants, click and open another activity with the book info there.

Few points to be noted:

Here's my Github repo: ISBN Scanner

I don't know what to do now, I'm getting mad at this. >:(

1 Answers1

0

I have checked your repo and i have found that you are not getting booklist and getting error while parsing json data.

here what I got in exception No value for industryIdentifiers May be you are doing something wrong here....

JSONArray industryIdentifiers = book_info.getJSONArray("industryIdentifiers");
    if (industryIdentifiers.length() == 1) {
         JSONObject obj = industryIdentifiers.getJSONObject(0);
         ISBN = obj.getString("type") + ": " + obj.getString("identifier");
    } else if (industryIdentifiers.length() == 2) {
         JSONObject obj1 = industryIdentifiers.getJSONObject(0);
         JSONObject obj2 = industryIdentifiers.getJSONObject(1);
         ISBN = obj1.getString("type") + ": " + obj1.getString("identifier") + " - "
         + obj2.getString("type") + ": " + obj2.getString("identifier");
    }
Log.d("ListBook",bookList.toString());
adapter = new MyAdapter(bookList, getApplicationContext());
recyclerView.setAdapter(adapter);

print your book list before attaching it to the adapter also, print exception in a catch block

catch (JSONException e) {
    Log.d("ListBook",e.getMessage());
    e.printStackTrace();
}
Gulab Sagevadiya
  • 872
  • 1
  • 8
  • 20
  • 1
    I didn't get what's wrong with the 'industryIdentifiers' JSON, it's working when I Click and then it opens a book info activity. But it isn't showing nothing into the RecyclerView to perform a click to the book_info. Could you please explain me more abou it? –  Mar 14 '22 at 16:28
  • First, print your JSON response and then get data from that response. i am pretty sure that only the data extraction part has some mistakes. your other recycler view code is perfectly fine – Gulab Sagevadiya Mar 15 '22 at 04:15