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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:03:29+00:00 2026-05-24T20:03:29+00:00

I use a GalleryView to display string with a BaseAdapter No problem to change

  • 0

I use a GalleryView to display string with a BaseAdapter
No problem to change the background and text color depending on the item state (selector)

But I want to change the background and text color only if the item is clicked not just selected, the GalleryView item state changes with the selected event which is called when you fling around (the centered item is automatically selected)

In 2 words the background mustn’t change if the item isn’t clicked
How can I go with it ?

  • 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-24T20:03:30+00:00Added an answer on May 24, 2026 at 8:03 pm

    You must capture the selected event and change the background of the view to unselected.
    Store last clicked position to avoid changing its selected background. Also, store last clicked view to restore unselected background when another item is clicked without flinging:

        gallery = (Gallery) findViewById(R.id.gallery);
        gallery.setAdapter(new DaysGalleryAdapter(this, new int[]{R.layout.gallery_item}, new int[]{R.id.tv_gallery}));
        gallery.setOnItemClickListener(mOnGalleryClick);
        gallery.setOnItemSelectedListener(new OnItemSelectedListener() {
    
               @Override
               public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                   if(position != savedClickedPosition) 
                       view.setBackgroundResource(R.drawable.bg_unselected);
               }
    
               @Override
               public void onNothingSelected(AdapterView<?> parent) {
                // TODO Auto-generated method stub
    
               }
    
       }); 
    
       private OnItemClickListener mOnGalleryClick = new OnItemClickListener(){
    
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    
            lastItemSelected.setBackgroundResource(R.drawable.tab_bg_unselected);
            view.setBackgroundResource(R.drawable.tab_bg_selected);
            lastItemSelected = view;
            savedClickedPosition = position;
            // Do stuff
        }       
       };
    

    If it’s too late for you Fluckysan at least hope it helps to anyone who’s having the same problem.
    Happy coding!

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

Sidebar

Related Questions

use a reapeter to display data, but sometimes the data is to big to
Use case: 3rd party application wants to programatically monitor a text file being generated
use this website a lot but first time posting. My program creates a number
Use case: I've just entered insert mode, and typed some text. Now I want
I'm using the jQuery GalleryView plugin. I've use the plugin on one page and
use WWW::Mechanize; my $mech = WWW::Mechanize->new; $mech->get( $url ); say $mech->text; How could I
I use Firebug and the Mozilla JS console heavily, but every now and then
Hi All I tried to use SurfaceView, but the view appeared black and nothing
Use http://jobs.sitesixteen.com/ for reference. I'm using YQL for the city, state auto-complete. IF you
I'm trying to use Android GalleryView to implement a view that can scroll horizontally

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.