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

  • Home
  • SEARCH
  • 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 6606567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:24:35+00:00 2026-05-25T19:24:35+00:00

I want to use Gallery as a horizontal menu so I’ve taken the code

  • 0

I want to use Gallery as a horizontal menu so I’ve taken the code for the Gallery tutorial to use TextViews instead of ImageViews by using a String[] and changing the adapter’s getView((...) method as follows…

public View getView(int position, View convertView, ViewGroup parent) {
    TextView tv = new TextView(mContext);
    tv.setText(mMenuItems[position]);
    tv.setLayoutParams(new Gallery.LayoutParams(150, 100));
    return tv;
}

The problem I have now is as shown in the image…

enter image description here

As you can see, what should be the ‘selected’ TextView is ‘greyed’ (although I can select it) and the other items are ‘highlighted and I’d like the reverse. So the question is what is Gallery doing to cause this and how do I override it?

UI stuff is a weak point of mine (I’m learning gradually honest) but I think I need to define styles as explained here…Definining styles and I understand what’s being explained but how do I get the Gallery to automatically apply the styles I define? Do I have to apply the styles the TextViews I return from the adapter’s getView(...) method or can I apply them ‘globally’ to the Gallery somehow?

  • 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-25T19:24:36+00:00Added an answer on May 25, 2026 at 7:24 pm

    You can leverage getSelectedItemPosition() to update the view accordingly but you’ll need a reference to the Gallery view (mGallery below):

    public View getView(int position, View convertView, ViewGroup parent) {
        TextView tv = new TextView(mContext);
        tv.setText(mMenuItems[position]);
        tv.setLayoutParams(new Gallery.LayoutParams(150, 100));
        if (position == mGallery.getSelectedItemPosition()) {
            // set tv properties to make it look selected
        } else {
            // set tv properties to make it look unselected
        }
        return tv;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a user control ( gallery.ascx ) and I want to use the
I want to use following selector drawable for android gallery image will it work
I have an image gallery i want to use portrait images but every portrait
I'm using wordpress with Smooth Gallery for showing featured news slider, and i want
This is killing me! I'm using django-filebrowser, and I want to create a gallery
I want to use an Android Gallery but draw the items from right to
I am new to using inherited resources and want to use it for polymorphic
I want to place a photo gallery on my wordpress blog. I use NextGEN
I have an image located at: http://ww2.sinaimg.cn/bmiddle/8c9772a0jw1dm10273empj.jpg I want use android gallery app to
I want to use the Brilliant Gallery (Drupal) to show a public Picasa album.

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.