I do not check all your code, but I see several problems:
1.
grid.setAdapter(new ImageAdapter(this));//Load the GridView final ImageAdapter im = new ImageAdapter(this); im.notifyDataSetChanged();
Not sure what this should do, you create a new ImageAdapter, and then a second one and call notifyDataSetChanged on it, which seems pretty useless as it is not attached to any kind. 2. Your ImageAdapter class is broken, especially the getView method. The main idea of getView is that you get a convertView transformation. If it is zero, create a view and set the information in it. If it is not null, reuse convertView and set the information in it. In your code, you only set information if the view is null, so as soon as you scroll or change the data, it will try to process the views and you will not change their contents.
The method should be something like
public View getView(int position, View convertView, ViewGroup parent) { View v = convertView; if (v == null){
You can also save the link to your adapter and call notifyDataSetChanged if you want the GridView to notifyDataSetChanged its contents.
Finally, you probably don't want the getItemId method in your ImageAdapter to return 0 all the time, since the GridView uses this identifier to manage the redesigned views and all. A simpler implementation would be
public long getItemId(int position){ return position; }
It may also be useful to populate the getItem method.
source share