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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:35:53+00:00 2026-06-06T22:35:53+00:00

See Deepa answer for the solution :) I read all of the solution given

  • 0

See Deepa answer for the solution 🙂

I read all of the solution given in StackOverFlow but none seems to work in my case. The thing is I have several button in my app, which will all react differently onto user action. For exemple, when the app is launched, all the button but two are disabled. So i set the default drawable onto my XML. The when I open a file all of them are clickable but some of those, when pressed need to stay pressed (I’ve done that) but the others just need to be pressed and then unpressed which I can’t do. By the way, all of the button got different background, that is why I do not use selector. Here are some printscreen :

enter image description here

enter image description here

So as you can see I manage the default state and the “checked state” (pressed for “ever”) but I can’t set a clicked state that just press the button then, when the action is finished return into the unpressed state. Because I know that the onClick is call after the touch so it doesn’t work to.

  • 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-06T22:35:54+00:00Added an answer on June 6, 2026 at 10:35 pm

    Try this..

    button.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if(event.getAction() == MotionEvent.ACTION_DOWN) {
                //change the button for pressed state..              
                button.setBackgroundResource(R.drawable.pressed);
            }       
        }
    
        if(event.getAction()==MotionEvent.ACTION_UP) {
            //After pressing the button again change the image for button as 
            button.setBackgroundResource(R.drawable.normal);
        }
    });
    

    i hope it helpful to you…

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

Sidebar

Related Questions

I see there are techniques available to have deep models in Backbone, but how
I can't see to find an answer for this, but it's been bugging me
So because Javolution does not work ( see here ) I am in deep
see this demo from jquery ui you have to hold down the Ctrl key
See title. Additionally, how can I tell if a given child element is only
[see later answer for more] I think this is just a simple rails question,
I have this following code: if (userValueSom01 == realResult01) { //answer = correct //count
Please see screenshot: Goal: id like to have comments nested 1 level deep The
I have been working on this a while. I see multi-dimensional arrays in php
Edit See @tim's solution below for the correct Groovy-esque approach to map recursion. Since

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.