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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:39:41+00:00 2026-05-30T00:39:41+00:00

I have an extended BaseAdapter that has LinearLayout children (an ImageView and a TextView

  • 0

I have an extended BaseAdapter that has LinearLayout children (an ImageView and a TextView in each) hooked up to a custom Gallery.

When I first launch my Activity, I want to call setSelection(position) to cause the ImageView to change its selector to the “selected” image. This works once I fling the Gallery, on subsequent selected children, but not the very first time the app is launched.

My selector:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true" 
    android:drawable="@drawable/home_image_select" /> 
<item android:state_selected="false" 
    android:drawable="@drawable/home_image" /> 
</selector>

My first guess was to call notifyDataSetChanged() on the adapter after calling setSelection(), which I attempted to do like this:

((CustomAdapter) gallery.getAdapter()).notifyDataSetChanged();

That didn’t do anything. I also tried overriding the setSelection() of the Gallery class to do this:

View v = this.getAdapter().getView(position, null, this);       
((ImageView) v.findViewById(R.id.gallery_image)).setSelected(true);

That doesn’t work either. Anything I’m missing or could try?

  • 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-30T00:39:43+00:00Added an answer on May 30, 2026 at 12:39 am

    I found the solution to my own problem by overwriting the setSelection() of Gallery (it worked after all).

     @Override
    public void setSelection(int position) {
        super.setSelection(position);
    
        View v = this.getAdapter().getView(position, null, this);
        v.setFocusable(true);
        v.requestFocus();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an extended from BaseAdapter class which used as a custom Adapter for
I have extended LinearLayout (vertical) to create a custom compound component. This in turn
I have extended the ASP.NET MVC Html Helper to include my own ValidationImage that
Hello I have an extended stored procedure that sends an error message. srv_sendmsg(pSrvProc, SRV_MSG_ERROR,
I have to open a page from class extended from javax.swing.AbstractAction class... Is that
I have an extended BaseAdapter in a ListActivity: private static class RequestAdapter extends BaseAdapter
I have extended org.eclipse.ui.editors.text.TextEditor to implement a custom editor. For this editor, I have
I have extended Django's User Model using a custom user profile called UserExtension .
I have a list Activity 4 which i have extended the BaseAdapter and the
I have a activity that extends listactivity, extended in this class i have a

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.