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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:45:48+00:00 2026-06-09T11:45:48+00:00

I have a GridView loaded in an Activity with fragments present. The GridView itself

  • 0

I have a GridView loaded in an Activity with fragments present. The GridView itself is not located in a Fragment. I created a customer adapter by way of BaseAdapter and everything is working peachy.

CustomerAdapter.java

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

    ImageView v = new ImageView( activity );
    Bitmap bmp = getBitmap( videoIds[ position ] );
    v.setImageBitmap( bmp );
    v.setAdjustViewBounds( true );
    v.setPadding( 5, 5, 5, 5 );
    v.setId( position );

    thumbnails[ position ] = bmp;

    return v;

}

I have a contextual action bar that will allow you to select videos to be uploaded, deleted etc.

videoGallery.setChoiceMode( GridView.CHOICE_MODE_MULTIPLE_MODAL );
videoGallery.setMultiChoiceModeListener( new MultiChoiceModeListener() { ... }

I want to add a border around the video when it is selected so with the padding all I need to do is add a background color. So I have this in the new MultiChoiceModeListener() section listed above:

@Override
public void onItemCheckedStateChanged( ActionMode mode, int position, long id, boolean checked ) {
ImageView image = (ImageView)videoGallery.findViewById( position );
    if( checked ) {
        image.setBackgroundColor( Color.YELLOW );
    } else {
        image.setBackgroundColor( Color.TRANSPARENT );
    }
    int count = videoGallery.getCheckedItemCount();
    if( count == 1 ) {
        mode.setSubtitle( "1 item selected." );
    } else if( count != 0 ) {
        mode.setSubtitle( count + " items selected." );
    } else {
        mode.setSubtitle( null );
    }
}

The problem is that the child view does not update. The title gets updated “1 item selected, 2 items selected, etc.) so I know the method is being called. And setting the background does produce a background so it’s not that I’m just not able to see the changes. The view itself is not updating. I’ve even set random IDs on the views when they are created and doing image.getId() provides the correct ID so I know it is finding the view. It is just not updating it. Any help?

  • 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-09T11:45:50+00:00Added an answer on June 9, 2026 at 11:45 am

    this doesn’t seem right:

    ImageView image = (ImageView)videoGallery.findViewById( position );
    

    the reason : position is set to be 0<=position<=count-1 . the id is a totally different thing .

    you need to update the raw data itself , and tell the adapter to update its views , for example using notifyDataSetChanged() .


    EDIT:

    that’s not the only problem . the real problem is that you create a new ImageView for the getView() , always (this , btw, causes a memory leak since adapterView caches its created views ) , instead of recycling it . you should really watch the video “the world of listView” .

    the reason that it doesn’t work for you is that you access old views that aren’t used anymore.

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

Sidebar

Related Questions

I have a UI that consists of a Gridview loaded with a custom adapter.
I have a GridView with JPEGs loaded from the network. I'm trying to find
I have a dropdownlist inside a gridview, that is loaded from a datasource when
I have a gridview control on the page. when the page is loaded for
I have a gridview control that can get loaded with multiple pages worth of
I have GridView and this grid has setup paging, but this paging not show
I have to create a gridview that is loaded with images from a specific
I have a gridview that is loaded from a DataSet, in which most of
Basically I have a gridview that is loaded when a DataSet is returned from
I have a gridview. its data source is a datatable that is loaded from

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.