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 3693284
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:21:35+00:00 2026-05-19T04:21:35+00:00

Hello I have a gridView which I use to show some pictures on (small

  • 0

Hello I have a gridView which I use to show some pictures on (small thumb of diffrent levels).
When the user finishes one level, I would like to change the thumb for that level. (Somehow show that it has been completed).

I created two thumbs for each level. One is the original and one that shows that the level is completed.

But how can i change the source of the images?

The code which I use to draw the images looks like this.

The main activity:

/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.maps);

  GridView gridview = (GridView) findViewById(R.id.gridview);
  gridview.setAdapter(new ImageAdapter(this));

  gridview.setOnItemClickListener(new OnItemClickListener() {
    @Override
      public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
        //Open the map which was clicked on, if there is one
        if(position+1 > 1){
            Toast.makeText(maps.this, "Level " + (position+1) + " is not yet available!", Toast.LENGTH_SHORT).show();
        }else{
            Toast.makeText(maps.this, "Opening Level " + (position+1), Toast.LENGTH_SHORT).show();
            Intent myIntent = new Intent(v.getContext(), Tutorial2D.class);
            startActivity(myIntent);
        }
      }
  });
}

The ImageAdapter Class:

public class ImageAdapter extends BaseAdapter {
private Context mContext;

public ImageAdapter(Context c) {
    mContext = c;
}

public int getCount() {
    return mThumbIds.length;
}

public Object getItem(int position) {
    return null;
}

public long getItemId(int position) {
    return 0;
}

// create a new ImageView for each item referenced by the Adapter
public View getView(int position, View convertView, ViewGroup parent) {
    ImageView imageView;
    if (convertView == null) {  // if it's not recycled, initialize some attributes
        imageView = new ImageView(mContext);
        imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        imageView.setPadding(8, 8, 8, 8);
    } else {
        imageView = (ImageView) convertView;
    }

    //Changing
    imageView.setImageResource(mThumbIds[position]);
    return imageView;
}



// references to our images
private Integer[] mThumbIds = {
        R.drawable.map1, R.drawable.map2, R.drawable.map3,
        R.drawable.map4, R.drawable.map5, R.drawable.map6,
        R.drawable.map7, R.drawable.map8, R.drawable.map9,
        R.drawable.map10, R.drawable.map11, R.drawable.map12,
        R.drawable.map13, R.drawable.map14, R.drawable.map15,
        R.drawable.map16, R.drawable.map17, R.drawable.map18,
        R.drawable.map19
};

}

  • 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-05-19T04:21:35+00:00Added an answer on May 19, 2026 at 4:21 am

    You could create a new bitmap based off a thumb and draw your extra graphics over it using a canvas. Then you could pass that bitmap to the imageview using imageView.setImageBitmap

    [edit]

    something like

    public View getView(int position, View convertView, ViewGroup parent) {
        ImageView imageView;
        if (convertView == null) {  // if it's not recycled, initialize some attributes
            imageView = new ImageView(mContext);
            imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
            imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
            imageView.setPadding(8, 8, 8, 8);
        } else {
            imageView = (ImageView) convertView;
        }
    
        if (mLevelfinished) {
    
            //create thumbnail bitmap
            mThumbBmp = BitmapFactory.decodeResource(mResources, mThumbIds[position]);
    
            //draw a check over the bitmap
            Canvas c = new Canvas(mThumbBmp);
            c.drawBitmap(mCheckBitmap, destX, destY, null);
    
            imageView.setImageBitmap(mThumbBmp);
        } else {
            imageView.setImageResource(mThumbIds[position]);
        }
    
        return imageView;
    }
    

    [edit2]

    I now see I kinda misunderstood your question.. doh. Instead of creating the level complete thumb dynamically, you already have thumbs for those. In that case, I would create another array that has those completed thumbs and pick the resource from the correct array. And to stick with arrays, maybe store the level completion in one as well:

    imageView.setImageResource((mLevelCompleted[position]) ? mThumbCompleteIds[position] : mThumbIds[position]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I have created and application which contains a gridview that is populated by
What I tried Hello Guys, I have made a GridView which I've filled over
Hello I have a bound field in gridview, which I am formating it to
Hello everyone I have a problem. I want to do a GridView with a
Hello I have like this 2 tables class User public int UserId{get;set;} { ....
Hello mates i have a page View All Applicants.aspx with gridview and a link
Hello i have a TextField on my scene. It haves only digits, user input
I have a gridview that fill it with some data. <asp:GridView ID=GridView1 runat=server ClientIDMode=Static>
Hello I have this problem with PyQt4-dev-tools that include: * a user interface compiler
Hello have following strange issue, can vertical center the menu text if it's one

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.