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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:23:14+00:00 2026-06-06T15:23:14+00:00

I have 4 buttons in my layout – they are switchers between 4 possible

  • 0

I have 4 buttons in my layout – they are switchers between 4 possible contents of View. Any time one of these buttons is pressed I need to highlight it (simply load other background, other image and change the color of the text). Trouble is, I need this to be done from the moment button is touched (not AFTER the click) and until other button is pressed. Simple use of onClick() methods won’t be very good because I’d have to check if other buttons are already highlighted, and also changes will be made only AFTER the click. Any good solution for that?

  • 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-06T15:23:15+00:00Added an answer on June 6, 2026 at 3:23 pm

    How about an onFocusChange listener?

    button.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                // set the background, image and color for focused
            } else {
                // set the background, image and color back to normnal
            }
        }
    });
    

    Set one of those for each button and you should be all set.

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

Sidebar

Related Questions

I have many buttons in my layout and they work well. I want to
i have one main relative layout in that i have buttons and in middle
Right now I have these buttons that line up nicely, but they have some
I have 4 buttons on my layout. One is the Correct Answer and 3
I have two buttons in my layout say b1 and b2. By pressing b1
I have two buttons in my xml layout as shown bellow. I used an
I have a linear layout with several buttons in it. The button images are
How to align the buttons bottom of the screen.In the layout i have header
I have different elements in my layout: Buttons, RadioButtons, EditText, a ListView and I
I have 2 buttons to switch between 2 layouts in the same activity: clicking

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.