Create Multiple Columns ListView from JSON Data using Retrofit2 in Android Example

In this example, we will create a sample application with single activity having a ListView with custom BaseAdapter to have multi columns with data from JSON object which we will get from dummy JSON file on the server. To make real server requests we will use Retrofit2.

This example app will discuss a challenge to parse JSON Object into ListView.

Let’s quickly start with an empty sample project.

Our directory structure will look like this.

Step 1) Add Retrofit2, okkhttp3, Gson, Converter Gson dependencies into Module: app build.gradle.

Copy paste these in “dependencies” section after that click on “Sync now“.

Step 2) Create a model file “MyModel” to map response from server side.



Step 3) Create three file under “service” package

ApiClientBuilder class file ( Will have Retrofit2 and okhttp3 initialization variables ).
ApiService ( A service file having calls to server )
ApiClient ( interface file defining nature and type of call )


Step 4) MainActivity class will have a server call, in response, it will call custom BaseAdapter.

Step 5) Create List layout Adapter class “CustomListAdapter” extending “BaseAdapter



Step 6) Now we work on Layouts MainActivity (activity_main.xml) and Custom List layout (json_data_list.xml)




Step 7) Last But Not Least 🙂 we need to add “Internet” permission as we are making the real server call.

Open “AndroidManifest.xml” then add below line immediately after “manifest” before “application” tag.

Find source find on Github here

That’s it Guys let me know if you face any issue in implementing this.

Thanks and happy Coding 🙂

Leave a Reply

Notify of