Simplified Coding

  • About
  • Contact Us
  • Advertise
  • Privacy Policy
You are here: Home / Android Application Development / Android Advance / Android Custom GridView with Images and Texts using Volley

Android Custom GridView with Images and Texts using Volley

January 10, 2016 by Belal Khan 81 Comments

In this post we will create an Android Custom GridView Example Application. In this android example we will get the images from server and will display in the grid. So we will be using.

  • Web API to get the data and
  • Volley library to fetch the data from Web API

After the completion our gridview will look like this.

android custom gridview

Android Custom GridView

So if you want to create the same then read the full post.

Creating an Android Custom GridView

Creating our Web API

The first thing needed for our Android Custom GridView project is a web api that would give us all the data to display in our GridView. Though I will not be covering the creating an API part. Below you can see the URL and this URL will give me the data for my Android Custom GridView.

http://www.simplifiedcoding.net/demos/SuperHeroes/superheroes.php

If you would go to the above given URL you will see the following JSON.

JSON String
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
[
   {
      "image":"http://www.simplifiedcoding.net/demos/SuperHeroes/dhruva.jpg",
      "name":"Super Commando Dhruva"
   },
   {
      "image":"http://www.simplifiedcoding.net/demos/SuperHeroes/parmanu.jpg",
      "name":"Parmanu"
   },
   {
      "image":"http://www.simplifiedcoding.net/demos/SuperHeroes/nagraj.jpg",
      "name":"Nagraj"
   },
   {
      "image":"http://www.simplifiedcoding.net/demos/SuperHeroes/doga.jpg",
      "name":"Doga"
   },
   {
      "image":"http://www.simplifiedcoding.net/demos/SuperHeroes/tiranga.jpg",
      "name":"Tiranga"
   },
   {
      "image":"http://www.simplifiedcoding.net/demos/SuperHeroes/bheriya.jpg",
      "name":"Bheriya"
   }
]

This JSON would give data for our Android Custom GridView.

Now lets create a project in Android Studio for our Android Custom GridView.

Creating Android Custom GridView Project in Android Studio

  • Open Android Studio and create a new Project. I created AndroidCustomGridView.
  • As I told that I will be using Volley Library so first we need to add Volley Library to our Gradle Dependencies. So add volley inside the dependency block of your build.gradle file for app module.

build.gradle
1
2
3
4
5
6
7
8
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    
    //Volley Library - You need to add this line
    compile 'com.mcxiaoke.volley:library-aar:1.0.0'
}

  • Our Android Custom GridView project need internet permission so go to the manifest file and add internet permission.

AndroidManifest.xml
1
2
    <!-- INTERNET PERMISSION -->
    <uses-permission android:name="android.permission.INTERNET"/>

  • Now come to main layout file activity_main.xml of our Android Custom GridView app. Here we will create a GridView. Just use the below code.

activity_main.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="net.simplifiedcoding.androidcustomgridview.MainActivity">
 
    <GridView
        android:id="@+id/gridView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:columnWidth="90dp"
        android:gravity="center"
        android:horizontalSpacing="10dp"
        android:numColumns="3"
        android:stretchMode="columnWidth"
        android:verticalSpacing="10dp"></GridView>
 
</LinearLayout>

  • Now come to MainActivity.java and declare the following variables.

MainActivity.java
Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
public class MainActivity extends AppCompatActivity {
 
    //Web api url
    public static final String DATA_URL = "http://www.simplifiedcodingreaders.16mb.com/superheroes.php";
 
    //Tag values to read from json
    public static final String TAG_IMAGE_URL = "image";
    public static final String TAG_NAME = "name";
 
    //GridView Object
    private GridView gridView;
 
    //ArrayList for Storing image urls and titles
    private ArrayList<String> images;
    private ArrayList<String> names;

  • We need to initialize the GridView inside onCreate().

MainActivity.java
Java
1
2
3
4
5
6
7
8
9
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
 
        gridView = (GridView) findViewById(R.id.gridView);
    
    
    }

  • Now we will create a method to get the JSON Array from the API.

MainActivity.java
Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
    private void getData(){
        //Showing a progress dialog while our app fetches the data from url
        final ProgressDialog loading = ProgressDialog.show(this, "Please wait...","Fetching data...",false,false);
 
        //Creating a json array request to get the json from our api
        JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(DATA_URL,
                new Response.Listener<JSONArray>() {
                    @Override
                    public void onResponse(JSONArray response) {
                        //Dismissing the progressdialog on response
                        loading.dismiss();
 
                        //Displaying our grid
                        showGrid(response);
                    }
                },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
 
                    }
                }
        );
 
        //Creating a request queue
        RequestQueue requestQueue = Volley.newRequestQueue(this);
        //Adding our request to the queue
        requestQueue.add(jsonArrayRequest);
    }

  • Once we got the JSON Array as the response we are calling method showGrid() and passing the JSON Array. So We will create this method to display our grid. But before we need an Adapter that would create all the needed number of ImageViews to the Grid, and before creating the adapter 😛 we need to create a Custom Volley Request for our NetworkImageView.
  • To display the images from the URL, I am going to use Volley’s NetworkImageView same as we did in many previous posts. So first create a class named CustomVolleyRequest.java and write the following code.

MainActivity.java
Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package net.simplifiedcoding.androidcustomgridview;
import android.content.Context;
import android.graphics.Bitmap;
import android.support.v4.util.LruCache;
 
import com.android.volley.Cache;
import com.android.volley.Network;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.BasicNetwork;
import com.android.volley.toolbox.DiskBasedCache;
import com.android.volley.toolbox.HurlStack;
import com.android.volley.toolbox.ImageLoader;
/**
* Created by Belal on 12/5/2015.
*/
 
public class CustomVolleyRequest {
 
    private static CustomVolleyRequest customVolleyRequest;
    private static Context context;
    private RequestQueue requestQueue;
    private ImageLoader imageLoader;
 
    private CustomVolleyRequest(Context context) {
        this.context = context;
        this.requestQueue = getRequestQueue();
 
        imageLoader = new ImageLoader(requestQueue,
                new ImageLoader.ImageCache() {
                    private final LruCache<String, Bitmap>
                            cache = new LruCache<String, Bitmap>(20);
 
                    @Override
                    public Bitmap getBitmap(String url) {
                        return cache.get(url);
                    }
 
                    @Override
                    public void putBitmap(String url, Bitmap bitmap) {
                        cache.put(url, bitmap);
                    }
                });
    }
 
    public static synchronized CustomVolleyRequest getInstance(Context context) {
        if (customVolleyRequest == null) {
            customVolleyRequest = new CustomVolleyRequest(context);
        }
        return customVolleyRequest;
    }
 
    public RequestQueue getRequestQueue() {
        if (requestQueue == null) {
            Cache cache = new DiskBasedCache(context.getCacheDir(), 10 * 1024 * 1024);
            Network network = new BasicNetwork(new HurlStack());
            requestQueue = new RequestQueue(cache, network);
            requestQueue.start();
        }
        return requestQueue;
    }
 
    public ImageLoader getImageLoader() {
        return imageLoader;
    }
}

  • Now lets create the Adapter for our GridView. Create a class named GridViewAdapter.java and write the following code.

GridViewAdapter.java
Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package net.simplifiedcoding.androidcustomgridview;
 
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
 
import com.android.volley.toolbox.ImageLoader;
import com.android.volley.toolbox.NetworkImageView;
 
import java.util.ArrayList;
 
/**
* Created by Belal on 12/22/2015.
*/
public class GridViewAdapter extends BaseAdapter {
 
    //Imageloader to load images
    private ImageLoader imageLoader;
 
    //Context
    private Context context;
 
    //Array List that would contain the urls and the titles for the images
    private ArrayList<String> images;
    private ArrayList<String> names;
 
    public GridViewAdapter (Context context, ArrayList<String> images, ArrayList<String> names){
        //Getting all the values
        this.context = context;
        this.images = images;
        this.names = names;
    }
 
    @Override
    public int getCount() {
        return images.size();
    }
 
    @Override
    public Object getItem(int position) {
        return images.get(position);
    }
 
    @Override
    public long getItemId(int position) {
        return 0;
    }
 
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        //Creating a linear layout
        LinearLayout linearLayout = new LinearLayout(context);
        linearLayout.setOrientation(LinearLayout.VERTICAL);
 
        //NetworkImageView
        NetworkImageView networkImageView = new NetworkImageView(context);
 
        //Initializing ImageLoader
        imageLoader = CustomVolleyRequest.getInstance(context).getImageLoader();
        imageLoader.get(images.get(position), ImageLoader.getImageListener(networkImageView, R.mipmap.ic_launcher, android.R.drawable.ic_dialog_alert));
 
        //Setting the image url to load
        networkImageView.setImageUrl(images.get(position),imageLoader);
 
        //Creating a textview to show the title
        TextView textView = new TextView(context);
        textView.setText(names.get(position));
 
        //Scaling the imageview
        networkImageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        networkImageView.setLayoutParams(new GridView.LayoutParams(200,200));
 
        //Adding views to the layout
        linearLayout.addView(textView);
        linearLayout.addView(networkImageView);
 
        //Returnint the layout
        return linearLayout;
    }
}

  • Now come back to MainActivity.java. We will now create the showGrid() method.

MainActivity.java
Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
    private void showGrid(JSONArray jsonArray){
        //Looping through all the elements of json array
        for(int i = 0; i<jsonArray.length(); i++){
            //Creating a json object of the current index
            JSONObject obj = null;
            try {
                //getting json object from current index
                obj = jsonArray.getJSONObject(i);
 
                //getting image url and title from json object
                images.add(obj.getString(TAG_IMAGE_URL));
                names.add(obj.getString(TAG_NAME));
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
        //Creating GridViewAdapter Object
        GridViewAdapter gridViewAdapter = new GridViewAdapter(this,images,names);
 
        //Adding adapter to gridview
        gridView.setAdapter(gridViewAdapter);
    }

  • Now at last just call the method getData() inside onCreate().
  • So the final code for MainActivity.java would be.

MainActivity.java
Java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package net.simplifiedcoding.androidcustomgridview;
 
import android.app.ProgressDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.GridView;
 
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonArrayRequest;
import com.android.volley.toolbox.Volley;
 
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
 
import java.util.ArrayList;
 
public class MainActivity extends AppCompatActivity {
 
    //Web api url
    public static final String DATA_URL = "http://www.simplifiedcodingreaders.16mb.com/superheroes.php";
 
    //Tag values to read from json
    public static final String TAG_IMAGE_URL = "image";
    public static final String TAG_NAME = "name";
 
    //GridView Object
    private GridView gridView;
 
    //ArrayList for Storing image urls and titles
    private ArrayList<String> images;
    private ArrayList<String> names;
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
 
        gridView = (GridView) findViewById(R.id.gridView);
 
        images = new ArrayList<>();
        names = new ArrayList<>();
 
        //Calling the getData method
        getData();
    }
 
    private void getData(){
        //Showing a progress dialog while our app fetches the data from url
        final ProgressDialog loading = ProgressDialog.show(this, "Please wait...","Fetching data...",false,false);
 
        //Creating a json array request to get the json from our api
        JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(DATA_URL,
                new Response.Listener<JSONArray>() {
                    @Override
                    public void onResponse(JSONArray response) {
                        //Dismissing the progressdialog on response
                        loading.dismiss();
 
                        //Displaying our grid
                        showGrid(response);
                    }
                },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
 
                    }
                }
        );
 
        //Creating a request queue
        RequestQueue requestQueue = Volley.newRequestQueue(this);
        //Adding our request to the queue
        requestQueue.add(jsonArrayRequest);
    }
 
 
    private void showGrid(JSONArray jsonArray){
        //Looping through all the elements of json array
        for(int i = 0; i<jsonArray.length(); i++){
            //Creating a json object of the current index
            JSONObject obj = null;
            try {
                //getting json object from current index
                obj = jsonArray.getJSONObject(i);
 
                //getting image url and title from json object
                images.add(obj.getString(TAG_IMAGE_URL));
                names.add(obj.getString(TAG_NAME));
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
        //Creating GridViewAdapter Object
        GridViewAdapter gridViewAdapter = new GridViewAdapter(this,images,names);
 
        //Adding adapter to gridview
        gridView.setAdapter(gridViewAdapter);
    }
 
}

  • Thats all for the coding part, now simply run your application now and you will see the following output.
android custom gridview

Android Custom GridView

  • Bingo! our custom Android GridView is working absolutely fine. If you are getting any trouble you can get my code from GitHub via the link given below.

[wp_ad_camp_1]

Android Custom GridView Example 

Some More Android Tutorials You Should Check 

  • Android Custom ListView with Images and Text
  • Android Feed Example using Volley

Thats all for this android custom gridview tutorial. You can leave your comments for any feedback or query regarding this android custom gridview tutorial. And please support by sharing the tutorial to your social profiles. Thank You 🙂

Sharing is Caring:

  • Tweet
  • Share on Tumblr
  • More
  • Pocket
  • Print
  • Email

Related

Filed Under: Android Advance, Android Application Development Tagged With: android custom gridview, android gridview, gridview android

About Belal Khan

I am Belal Khan, I am currently pursuing my MCA. In this blog I write tutorials and articles related to coding, app development, android etc.

Comments

  1. Kevin says

    January 10, 2016 at 3:49 pm

    Great tutorial! thank Belal, Can you make a tutorial for Custom Recyclerview in Tab fragments?

    Reply
    • Belal Khan says

      January 10, 2016 at 4:13 pm

      Your welcome buddy.. just wait I will try to post the tutorial for your query ASAP.

      Reply
      • Kevin says

        January 10, 2016 at 4:17 pm

        Thanks Belal, You are truly the best! More knowledge and power to my great sir.

        Reply
  2. surya says

    January 16, 2016 at 3:37 pm

    Hi, I have tried it.. but it is not fetching data.. Hope some problem with url..

    Reply
    • Belal Khan says

      January 16, 2016 at 3:40 pm

      Yeah as I gave the hosting details publically.. some one tried it for spamming and they blocked the hosting account 😛

      You have to create your own web API to make it work

      Reply
      • surya says

        April 9, 2016 at 1:14 pm

        hello sir
        this app cand start and show msg fetching dada thats
        no resutl show and display in logcat

        04-09 18:42:11.706 9483-9526/com.example.mk4.androidcustomgridview I/qtaguid: Tagging socket 42 with tag 3833279300000000(-1204607085) for uid -1 failed errno=-2
        04-09 18:42:11.706 9483-9526/com.example.mk4.androidcustomgridview I/NetworkManagementSocketTagger: tagSocketFd(42, -1204607085, -1) failed with errno-2

        Reply
    • Belal Khan says

      January 16, 2016 at 3:56 pm

      I have corrected the url now try using this url
      http://www.simplifiedcoding.16mb.com/superheroes.php

      Reply
      • August says

        August 1, 2016 at 9:01 am

        Hi Belal. The ProgressDialog won’t stop loading. Please help. Anyone successfully done this?

        Reply
        • Wong Chun Kit says

          November 12, 2016 at 5:29 pm

          i also stuck in this problem ,who else can help , in hurry , need help .(T.T)

          Reply
          • Deniz Yunus Göğüş says

            February 24, 2017 at 4:30 pm

            Maybe late reply, but I found a solution,

            write this :
            new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
            loading.dismiss();
            Toast.makeText(getApplicationContext(), error.getMessage() + “.”, Toast.LENGTH_LONG).show();
            }
            instead of this :
            new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {

            }
            }

          • FERNANDO says

            May 16, 2017 at 12:41 am

            Hey I got the same error, did you solve it? I would appreciate your help.
            Thanks.

  3. leo says

    January 18, 2016 at 3:10 pm

    Would you send me the superheros.php for me to see because I can not fetch data make myself.

    Reply
  4. leo says

    January 18, 2016 at 4:39 pm

    would you send the superheros.php because I can not fetch data when I create my own webAPI

    Reply
  5. yasir says

    January 19, 2016 at 9:28 am

    Nice Tutorial …..Bilal can you make tutorial on Displaying data into the graph both locally and from online resource….thanks

    Reply
  6. benny says

    January 20, 2016 at 4:23 am

    would you write the gridview onclicklistener to view the full image?

    Reply
  7. benny says

    January 20, 2016 at 11:06 am

    would you write a tutorial that gridview onitemclicklistener to display the full image?

    Reply
  8. Marconni says

    January 20, 2016 at 2:40 pm

    Thank you very much for this example because it has helped me a lot. I made the example, I am now trying a new activity, by an intent to show the image and name, I have not got, I keep trying. thank you.

    Reply
    • leo says

      January 21, 2016 at 10:45 am

      I also create this activity too,would you help me??

      Reply
  9. leo says

    January 21, 2016 at 10:39 am

    Thank you very much for this example because it has helped me a lot. I made the example, I am now trying a new activity, by an intent to show the image and name, I have not got, I keep trying. thank you

    Reply
    • Fernando says

      May 18, 2017 at 3:39 am

      Hey did you solve it? I’m trying to do the same thing but no luck. I would appreciate if you could help me.
      Thanks!

      Reply
  10. Irsan says

    February 6, 2016 at 2:23 am

    Nice tutorial…. Can I download file superhero.php ??

    Reply
  11. azaur says

    February 12, 2016 at 9:54 am

    Dude give the working code including android.
    I am getting unfortunately stopped error.

    Reply
  12. Iskas says

    February 15, 2016 at 7:15 pm

    How to add one more text under name in girdview ?

    Reply
  13. Aleksander says

    March 1, 2016 at 6:05 pm

    Hi!
    Its my file superhero.php
    If you are using the emulator then the file should be available http://10.0.2.2/api/superhero.php
    I have it available as http://10.0.3.2/api/superhero.php

    $row[5],
    ‘name’=>$row[1])
    );
    }

    echo json_encode($result);

    mysqli_close($con);

    Reply
  14. vinodh says

    March 19, 2016 at 5:54 am

    “gradle.builde ” where it locates in android eclipse. and how to it update!!!!!!!!!

    Reply
  15. Mounika says

    March 21, 2016 at 5:27 am

    Hi,

    Am getting the error unfortunately app has been stopped,

    and I gave this code for fragment
    In getData()method , am getting the error
    I have to use getActivity() or getContext() but am getting the same error for both of them
    pls suggest me

    Reply
    • Praku says

      June 1, 2016 at 4:50 am

      I am also getting the same problem in fragments

      Reply
      • Praku says

        June 6, 2016 at 7:00 am

        Sorted out !!
        you just define Context ctx in the mainActivity and use ctx in place of getActivity().

        Reply
  16. M Argus Chopin Gyver says

    March 22, 2016 at 10:55 am

    Hi, can i use it for making a grid view without the photo ?

    If it yes, what I can remove from the code ?

    Reply
  17. Dian Putri says

    March 25, 2016 at 3:45 am

    Great tutorial Belal, I have followed this tutorial for my project.

    But I have something in my mind.
    Is there any code for the image shown in the grid view be able to be clicked and show the enlarge the picture?

    Reply
  18. Prakhar says

    March 30, 2016 at 8:49 am

    Hi Bilal,

    could you please help in how to delete images from gridView.

    thanks

    Reply
  19. mebin says

    April 5, 2016 at 12:40 pm

    plzz help
    how to add gridview onclicklistener ???

    Reply
  20. surya says

    April 9, 2016 at 1:23 pm

    hello can u give me superhero.php file plz..

    Reply
  21. Nawel says

    April 12, 2016 at 1:54 pm

    hello can u give me superhero.php file plz.. :'(

    Reply
  22. Avinash Yadav says

    May 4, 2016 at 2:06 am

    Hi Belal,
    Can you please send superhero.php?
    Please send this as soon as possible.
    Thanks and regards,
    Avinash Yadav
    [email protected]

    Reply
  23. Pratik Chauhan says

    May 4, 2016 at 10:45 am

    can u make the next activity that show single_row when click on a particular click .Please i tried a lot but not getting the content on like Full description.class

    Reply
  24. Pratik Chauhan says

    May 4, 2016 at 10:47 am

    can u please make single row activity of this file showing particular image

    Reply
  25. DPR says

    May 6, 2016 at 12:56 pm

    can you please send the superheros.php to my mail [email protected]

    Reply
    • Jeffrey says

      July 24, 2016 at 7:24 am

      hi , do u receive the superheros.php file ?can u forward to me ? [email protected]

      Reply
  26. Praku says

    June 1, 2016 at 6:22 am

    Thanks for the tutorial 🙂

    Reply
  27. Tarun Talreja says

    June 10, 2016 at 11:40 am

    Hey i am getting please wait fetching data and it is not loading anything can u help me?

    Reply
  28. poudel anuj says

    June 26, 2016 at 4:50 pm

    can you ,please provide the php file for image and text parsing

    Reply
  29. syed muhammad awais says

    July 1, 2016 at 9:43 am

    Salam sir i need to know that how can i make my gridview responsive using volley , the grind view includes dynamic pictures and text i need to make them responsive those images to fit on screen perfectly those images are not from server i have stored them into drawables and i am picking them from there so yes i can not use networkimageview of volley

    Reply
  30. windcjg says

    July 3, 2016 at 3:13 am

    Thank you for the great app !
    May I have the file (superhero.php) ?

    Please…
    [email protected]

    Reply
  31. Dipti Agravat says

    July 22, 2016 at 5:15 pm

    get ic_alert image 🙁

    Reply
  32. Dipti Agravat says

    July 23, 2016 at 5:08 am

    image not set in gridview only show aleart dialog. helm me 🙁

    Reply
    • shashikant says

      October 14, 2016 at 5:06 am

      the url is not working..

      Reply
  33. Jeffrey says

    July 24, 2016 at 6:43 am

    hi belal , why dont u just upload the php code?

    Reply
  34. snehpatel says

    September 1, 2016 at 8:04 am

    hello can u give me superhero.php file pls!!!!!!!!!!

    Reply
  35. Rulli says

    September 16, 2016 at 7:11 am

    hello I got this error in logcat
    java.lang.NullPointerException: Attempt to invoke virtual method ‘int java.util.ArrayList.size()’ on a null object reference
    What could be the cause?

    Reply
  36. Irfan says

    September 17, 2016 at 8:44 am

    HI, Thank you for this nice tutorial. It helped me a lot. What if i want to send any post data with this request. How would i change the code ?

    Reply
    • Mamon says

      February 23, 2017 at 5:33 am

      i facing same problem can you help me brother?

      Reply
  37. Monica says

    September 20, 2016 at 11:38 am

    Hello it wont stop fetching data load progress.. and it doesn’t even display images can you help with the problem or can u plz send me superhero.php file..

    Reply
    • shashikant says

      October 14, 2016 at 5:09 am

      may be because of url is not working

      Reply
      • wong chun kit says

        November 12, 2016 at 5:20 pm

        ,”url”:”http:\/\/finalproject.16mb.com\/android\/uploads\/1.jpg”}
        this is my image url get from database . i think that is because of my url so my app cannot fetch the img data .my url is difference with the top of the img url given . but i follow the previous tutorial

        Reply
        • Fernando says

          May 16, 2017 at 11:36 pm

          Hey could you solve this? I would appreciate your help!
          Thanks.

          Reply
  38. Logan Griffin says

    November 13, 2016 at 9:50 pm

    Great tutorial! where can i add auth headers to the ImageLoader request?

    Reply
    • jun jie says

      November 14, 2016 at 5:09 am

      can u give me ur php file? i stuck on the url step , i get the img url like this :
      {“id”:”19″,”name”:”d1″,”url”:”http:\/\/www.finalproject.16mb.com\/android\/uploads\/19.jpg”}]}
      dun know wat problem that cause my url to show like this.

      Reply
      • Hamza Imtiaz says

        November 24, 2017 at 9:00 pm

        1.replace $response[‘images’] with $response in php file
        2.change ==> public static final String TAG_IMAGE_URL = “images”; to ====> “public static final String TAG_IMAGE_URL = “url” in your main class.

        Reply
  39. Nikhil Guttikonda says

    November 23, 2016 at 11:05 am

    progress Dialogue wont stop.. Fetching Data… please help me…

    Reply
    • Nikhil Guttikonda says

      November 23, 2016 at 11:08 am

      http://dasassociates.org/paym/uploads/demop.php this is my php file running on server.. but i didnt get images & title from server

      Reply
  40. hiep.vh says

    December 5, 2016 at 10:03 am

    Thank you for your tutorial
    Now I’m trying to make a application to view gridview of local image by voley, but when I try it always have java.lang.OutOfMemoryError exception, can you make a tutorial of this

    Reply
  41. Abhijeet Rajput says

    December 27, 2016 at 12:48 pm

    type org.json.JSONObject cannot be converted to JSONArray
    i m getting that error can anyone help me??

    Reply
  42. Nanthini says

    January 5, 2017 at 6:58 am

    dialogbox is not stopped..it shows Fetching Data…
    I tried your latest json too..but i get the same error.Would u Please help me

    Reply
    • Shashikant says

      January 5, 2017 at 5:05 pm

      Debug the app n check whether u r getting value from server or not

      Reply
  43. Deniz Yunus Göğüş says

    February 26, 2017 at 5:14 pm

    Hi, I have an error, so I created a question on stackoverflow, can u reply?
    http://stackoverflow.com/questions/16738279/android-org-json-jsonarray-cannot-be-converted-to-jsonobject

    Reply
  44. json says

    March 7, 2017 at 1:51 pm

    can we display .gif format in this application ?

    Reply
  45. Brian says

    March 15, 2017 at 2:51 pm

    Hi belal,
    thanks for this tutorial
    would you write a tutorial that gridview onitemclicklistener to display the full image?
    appreciate for your help..
    thanks…

    Reply
    • FERNANDO says

      May 19, 2017 at 3:48 pm

      Hey I want to do the same thing, did have any luck with this?
      Thanks!

      Reply
  46. nikhil pande says

    March 18, 2017 at 7:59 am

    gridview onitemclicklistener to display the full image to share? please

    Reply
  47. rahul says

    May 3, 2017 at 8:24 am

    how to set text below image in this gridview

    Reply
    • Adel Rafiee says

      May 4, 2017 at 6:55 am

      In the end of GridViewAdapter you have to put this line –> linearLayout.addView(textView); below the second line linearLayout.addView(networkImageView);

      like this:

      //Adding views to the layout
      linearLayout.addView(networkImageView);
      linearLayout.addView(textView);

      Reply
  48. Adel Rafiee says

    May 4, 2017 at 6:49 am

    Hello Belal
    Wonderful, It is a Great tutorial
    it works perfectly. many thanks man

    But i have a little problem with scrolling up, when I scroll down everything is fine, but when I scroll up from the end of the list, it’s not smooth and it jumps to end again and again. Did I miss anything here?

    I’m looking forward for your answer

    Reply
  49. Alaa khatib says

    July 20, 2017 at 12:25 am

    Hello Belal

    How to change getview() to use an existing layout_grid_item.xml which contains textview and imageview

    I hope you help me make this change

    thanks

    Reply
  50. Sandeep Kumar says

    September 12, 2017 at 7:40 am

    Hi
    I want to use my predefined layout. In the above code the layout is created in run time but i want to use my predefined layout in xml file. how can use the code and my predefined layout.

    Reply
  51. Nikhil Chandeshwar says

    September 23, 2017 at 8:05 am

    Hello everyone, here problem is with php script
    just follow this
    1) make an array like this
    $android = array();
    now
    $fetch_res = [‘image’=>’$image’,name=>’name’];
    array_push($android,$fetch_res);
    echo json_encode($android);

    You will get Output like Belal’s json result
    Thank You!!!

    Reply
  52. Kevin Perdana says

    December 27, 2017 at 4:48 pm

    If image show dialog alert picture,
    Add library compile ‘com.nostra13.universalimageloader:universal-image-loader:1.9.5’ in build.gradle

    Reply
  53. GaNs Oza says

    January 31, 2018 at 5:46 am

    hello @Belal Khan really thank you your all tut and blogs are help full for all android developer.

    i have use this Android-custom-gridview-images Code but i am some issue
    actually i get same as JSON Data and also get totally path in my grid view but in my application text View is show Proper Name and Image is not showing …?
    could u help me please .

    Thank you.

    Thank you

    Reply
  54. Sarika shrivastava says

    March 31, 2018 at 9:54 pm

    hello sir, i tried the above code with my own server i got the response array while running on postman chrome, but inside the android app Progressdialog is continuously loading, i am not getting the response at app end, even url is ok.

    Reply
  55. sagar says

    June 17, 2018 at 6:30 pm

    how to pass an argument in Volley GET request?

    Reply
  56. Pratik Vasani says

    June 23, 2018 at 6:48 am

    I have done successfully…!!!
    Thanks bro.
    Now i want to learn how fetch video from server in listview or recyclerview.
    please make one example on it.

    Thanks.
    God bless you.

    Reply

Leave a Reply to Fernando Cancel reply

Your email address will not be published. Required fields are marked *

Search




Download our Android App

Simplified Coding in Google Play

About Me

Belal Khan

Hello I am Belal Khan, founder and owner of Simplified Coding. I am currently pursuing MCA from St. Xavier's College, Ranchi. I love to share my knowledge over Internet.

Connect With Me

Follow @codesimplified
Simplified Coding

Popular Tutorials

  • Android JSON Parsing – Retrieve From MySQL Database
  • Android Login and Registration Tutorial with PHP MySQL
  • Android Volley Tutorial – Fetching JSON Data from URL
  • Android Upload Image to Server using Volley Tutorial
  • Android TabLayout Example using ViewPager and Fragments
  • Retrieve Data From MySQL Database in Android using Volley
  • Firebase Cloud Messaging Tutorial for Android
  • Android Volley Tutorial – User Registration and Login
  • Android Upload Image to Server Using PHP MySQL
  • Android Navigation Drawer Example using Fragments




About Simplified Coding

Simplified Coding is a blog for all the students learning programming. We are providing various tutorials related to programming and application development. You can get various nice and simplified tutorials related to programming, app development, graphics designing and animation. We are trying to make these things simplified and entertaining. We are writing text tutorial and creating video and visual tutorials as well. You can check about the admin of the blog here and check out our sitemap

Quick Links

  • Advertise Here
  • Privacy Policy
  • Disclaimer
  • About
  • Contact Us
  • Write for Us

Categories

Android Advance Android Application Development Android Beginners Android Intermediate Ionic Framework Tutorial JavaScript Kotlin Android Others PHP Advance PHP Tutorial React Native

Copyright © 2017 · Simplified Coding· All rights Reserved. And Our Sitemap.All Logos & Trademark Belongs To Their Respective Owners·

loading Cancel
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.