Skip to content Skip to sidebar Skip to footer

Using Gridview Image In Fragment

I am developing a android app which uses a GridView to show my images in a class extends Fragment. But when I run my code, I met error. This error show: 'NullPointerException' in G

Solution 1:

Your GridView is not initialized and hence error at gridView.setAdapter(adapter);.

The call,

 GridView gridView;

only declares your GridView, however in order to use it you must initialize it as

gridView = new GridView(context);

or

gridView = (GridView) view.findViewById(your id);

Post a Comment for "Using Gridview Image In Fragment"