Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8292235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:24:24+00:00 2026-06-08T13:24:24+00:00

I had a list contains images, each time the user clicked on the image

  • 0

I had a list contains images, each time the user clicked on the image and then on the grid view the image will be displayed on the grid view, this part i already done and it`s working.
The problem is when the user starting to scroll up/down, all the previous images on the grid starting to show in different places. My guess I have a problem with the getView function inside my adapter

public class GridAdapter extends BaseAdapter{

Context mContext;
public GridAdapter(Context con){
    mContext = con;
}

@Override
public int getCount() {
    // TODO Auto-generated method stub
    return Globals.obsImageMatrix.size();
}

@Override
public Object getItem(int arg0) {
    // TODO Auto-generated method stub
    return null;
}

@Override
public long getItemId(int position) {
    // TODO Auto-generated method stub
    return position;
}

@Override
public View getView(final int position, View convertView, ViewGroup arg2) {

     if(convertView==null){
        LayoutInflater vi = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = vi.inflate(R.layout.grid_image, null);
        Holder.image =(ImageView) convertView.findViewById(R.id.obsImage);
      //  Holder.image.setImageResource(R.drawable.blank);
     }
      Holder.image =(ImageView) convertView.findViewById(R.id.obsImage);
      Holder.image.setImageResource(Globals.obsImageMatrix.get(position));
    return convertView;
}



public static class Holder{
    public static ImageView image;
}

}

Globals.obsImageMatrix is a matrix that it`s size as the grid itself, that contain the images of the grid.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T13:24:25+00:00Added an answer on June 8, 2026 at 1:24 pm

    You do not use your ViewHolder correctly. Try this:

    @Override
    public View getView(final int position, View convertView, ViewGroup arg2) {
    
         ViewHolder holder = null;
         if(convertView==null){
            LayoutInflater vi = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = vi.inflate(R.layout.grid_image, null);
            holder = new ViewHolder();
            holder.image =(ImageView) convertView.findViewById(R.id.obsImage);
            convertView.setTag(holder);
         }else{
            holder = (ViewHolder)convertView.getTag(); 
         }
    
          holder.image.setImageResource(Globals.obsImageMatrix.get(position));
        return convertView;
    }
    
    public static class Holder{
        public ImageView image;
    }
    

    You have to read more about viewHolders to understand this pattern. There is a lot of posts on SO and google.

    Hope this will help you

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a pivot view, with 6 pivotitems. Each pivotitem contains a list of
I have a class that contains a list of objects. I previously had this
If i had a list of balls each of which has a color property.
I heard this today during interview for java developer. I had to list some
I have created a ListView which contains a list of items. Each item in
I had this site working outside of ruby on rails and then I moved
My page contains list of posts, each post has its own like button. The
I have a list where each li element contains two div inside one div
In C#: List<List<Point>> SectionList = new List<List<Point>>(); SectionList contains lists of points where each
I have a web service that contains this method: [WebMethod] public static List<string> GetFileListOnWebServer()

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.