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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:54:34+00:00 2026-06-12T19:54:34+00:00

I am using gridview with custom adapter. Each item in Grid contains an imageview

  • 0

I am using gridview with custom adapter. Each item in Grid contains an imageview and checkbox but I want last item to be a button.

Here is my code:

@Override
    public int getCount() {
        return thumbUrls.size()+1;
    }

I returned +1 in getcount to make getview called one extra time.

In getview: –

@Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        View row = convertView;
        ViewHolder holder;
        if(row==null)
        {
            row = layoutInflater.inflate(R.layout.griditem, parent, false);
            holder = new ViewHolder();
            holder.mainImage = (ImageView)row.findViewById(R.id.itemgrid);
            holder.checkBox = (CheckBox)row.findViewById(R.id.itemselected);
            row.setTag(holder);
        }
        else {
            holder = (ViewHolder)row.getTag();
        }
        if (position==(thumbUrls.size()+1)) { //this is just to show what i am trying to do.
        Button button = new Button(context);
        return button;
        }
        else
        {
            setImageSize(holder.mainImage);

            holder.mainImage.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    intent.putExtra("position", position);
                    intent.putStringArrayListExtra("MainUrls", mainUrls);
                    intent.putStringArrayListExtra("Thumbnails", thumbUrls);
                    context.startActivity(intent);
                }
            });

            holder.checkBox.setOnCheckedChangeListener(null);
            holder.checkBox.setTag(position);

            holder.checkBox.setChecked(positions.contains(thumbUrls.get(position)));
            holder.checkBox.setOnCheckedChangeListener(this);

            UrlImageViewHelper.setUrlDrawable(holder.mainImage, thumbUrls.get(position), R.drawable.extras_load);
        }
        return row;

    }
  • 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-12T19:54:35+00:00Added an answer on June 12, 2026 at 7:54 pm

    Instead of

        if (position==(thumbUrls.size()+1)) { //this is just to show what i am trying to do.
        Button button = new Button(context);
        return button;
        }
    

    use

        if (position == thumbUrls.size()) { 
        Button button = new Button(context);
        return button;
        }
    

    The first parameter position in getView starts at 0. You should also set an appropriate LayoutParameter for the Button.

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

Sidebar

Related Questions

I'm creating a custom view derived from GridView. This contains a custom ImageView with
I want to provide custom paging in grid view. <asp:GridView ID=gvFirst runat=server AutoGenerateColumns=false AllowPaging=true
I have followed Custom Pagination article to implement the custom pagination using GridView. I
I'm implementing a custom calendar using a GridView. For this Calendar I have 3
I am using C#.net I want to add custom edit/delete buttons to my GridView1
Hi i m using GridView with hovermenu and i want that when we click
I've already got my custom header drawing in my GridView using SetRenderMethodDelegate on the
I have one gridview in my windows form. Now i'm showing custom tooltip using
I have a grid view which is populated using a custom ImageAdapter class extending
I am using DevExpress's GridView. I have edit button working fine. I need to

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.