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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:05:24+00:00 2026-06-03T09:05:24+00:00

I have a gridview I created using this tutorial GridView Android , which works

  • 0

I have a gridview I created using this tutorial GridView Android, which works just fine. Now I’d like to overlay an image onto the item of the gridview if say the item is clicked. I’m not sure how to do this, whether I use another gridview and merge them or just have lots of image views :s. Just to clarify the question: How do I overlay onto gridview items? Thanks in advance!

  • 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-03T09:05:25+00:00Added an answer on June 3, 2026 at 9:05 am

    So there are a few ways you might achieve this but possibly the most flexible would be to use a custom view in the getView method.

    Add a LayoutInflater to your ImageAdapter class:

    private LayoutInflater mInflater;
    

    Initialize it in the constructor:

    public ImageAdapter(Context c) {
        mContext = c;
    
        // Initialise the inflater
        mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }
    

    This is used to inflate an xml view such as this:

    <RelativeLayout
      android:layout_width="fill_parent"
      android:layout_height="fill_parent">
        <ImageView
          android:id="@+id/mainImage"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
        />
        <ImageView
          android:id="@+id/overlayImage"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:visibility="gone"
        />
    </RelativeLayout>
    

    Inflate this view in the ImageAdapter class getView method

    public View getView(int position, View convertView, ViewGroup parent) {
    
        // RelativeLayout as used in the xml view
        RelativeLayout customView;
    
        if (convertView == null) {  // if it's not recycled, inflate
            customView = (RelativeLayout) mInflater.inflate(R.layout.customview, null);
        } else {
            imageView = (RelativeLayout) convertView;
        }
    
        // Get the mainImageView from the parent
        ImageView mainImage = (ImageView) customView.findViewById(R.id.mainImage);
        imageView.setImageResource(mThumbIds[position]);
    
        // Overlay view
        ImageView overlayImage = (ImageView) customView.findViewById(R.id.overlayImage);
        overlayImage.setImageResource(mOverlayThumbIds[position]); // new array containing overlay references
    
        return customView;
    }
    

    Then show the overlay image on click

    gridview.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
    
            ImageView overlayImage = (ImageView) v.findViewById(R.id.overlayImage);
            overlayImage.setVisibility(View.VISIBLE);
    
        }
    });
    

    This is a very basic example but hopefully you will find the approach useful.

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

Sidebar

Related Questions

I've created a calendar which works fine, using a GridView which has an OnClickListener.
I have a gridview to which I have created an Insert Template in the
I have a GridView to which I bind a dataTable that I manually created.
I have created a class doing some jobs like GridView inherit from System.Web.UI.WebControls.WebControl. public
I have this table I created manually, and I want to use a gridview
I have a field of type DateTime which is bound in gridview. Now, i
I have a gridview and in that gridview i created a list of imagebuttons
I have created a gridview with a column of checkboxes. I want the user
I have GridView which I can select a row. I then have a button
Here i have gridview which contain some values retrieved from database.We put radiobutton list

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.