mercredi 7 mars 2018

Volley & Glide Tutorial | Parse Json & display Content to a recyclerview Part 1



1-Overview :

In this tutorial you will learn how to parse a hosted json file and display the content to recyclerview
using Volley and Glide libraries :

Volley library : Volley is an HTTP library that makes networking for Android apps easier and most importantly, faster.

Glide : Glide is a fast and efficient open source media management and image loading framework for Android that wraps media decoding, memory and disk caching, and resource pooling into a simple and easy to use interface.

1.1- Final Result  (Demo) :



1.2- Our Layout :





1.3- Our JSON File:

its simply a file contains an array of JSON Objects and our object structor is like the following :
Note : we are hosting our Json File on Github you can check this link for full file content
json link : https://goo.gl/oX5Ztp



2- Preparing:

Start a new Android Studio Project


choose your target API


choose an empty activity then click finish

2-1 Import Required Libraries :

Inside build.gradle (Project: yourappname) add mavenCentral() repository :

and in build.gradle (Module: app) add the following implementations :



2-2 Package Structor :

add the following packages in your project :


3 Create a Model Class  :



3-1 Design Anime Item Row    : 

3-2 Design Activity main


3-3 ActivityMain.java



3-4 RecyclerView Adapter class


if you have any question please let me know in the comments section Thanks For reading my blog post

19 commentaires:

  1. thank you so much bro..
    can you help me? i need to show in the recycleview depends on user id..

    RépondreSupprimer
    Réponses
    1. hello MUHAMMAD ILHAM,
      you can send your user id to the recyclerview activity, depands on that id you must get a listitem related to that user then setup your adapter ...

      Supprimer
  2. Sir,I am waiting your new post on it

    RépondreSupprimer
    Réponses
    1. please wait my friend
      i cant post any new tutorial in this moment my laptop is broken..

      Supprimer
  3. Hi, great tutorial, for dummies where is the location of these files?

    3 Create a Model Class :

    3-1 Design Anime Item Row :

    3-2 Design Activity main

    3-3 ActivityMain.java

    3-4 RecyclerView Adapter class

    Thank you

    RépondreSupprimer
    Réponses
    1. hello Guys,sry for that i will updated the post soon..
      model class is a POJO class create it inside Model package
      anime item row and activity main inside the layout folder
      activity main java inside the Activities Package
      recyclerviewadapter inside Adapter package

      Supprimer
  4. hello how to add glide in my android studio

    RépondreSupprimer
    Réponses
    1. simply add these dependency in build.gradle

      // Glide library
      implementation 'com.github.bumptech.glide:glide:4.6.1'
      annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'

      Supprimer
  5. Hello,i have a problem when i use my API on this code i got this error "of type org.json.JSONObject cannot be converted to JSONArray",I try to google but i didnt found write solution.What shoud i change in this code,so it could work?

    RépondreSupprimer
  6. Great app....please provide the source code of part 2 of it

    RépondreSupprimer
    Réponses
    1. i will add the second tutorial once i fix my laptop
      please wait my friend

      Supprimer
  7. Hello sir ! I have a problem. I have a black page when launching. I checked two times my code. Can you help me ?

    RépondreSupprimer
    Réponses
    1. please provide your activity main code and your logcat
      also did you add the internet permission inside the manifest file

      Supprimer
    2. acually i forgot to add the permission so sorry for that add this line inside your manifest file

      ...

      Supprimer
  8. can you implementation interstitial ads on reycylerlistener

    RépondreSupprimer