How to Root Android Wear 5.0.1 Lollipop Devices – XDA TV

The Lollipop update for Android Wear devices has hit the market and people are … more

Android 5.0.2 and New Factory Images For Nexus 7 (Wi-Fi) Available

Android 5.0 is has been publicly available since early November, and the … more

Github Tutorial App Shows You How to Use… Github

Github can get pretty complicated and using it can become quite daunting, especially … more

Google Glass-like Clip-On For Regular Glasses Developed by Sony

For the price of $2,000, a pair of glasses that can run apps, take pictures, … more

Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

make a toggle button "greyed out"

OP smaskell

26th February 2011, 03:11 AM   |  #1  
OP Senior Member
Flag San Francisco
Thanks Meter: 45
 
463 posts
Join Date:Joined: Jan 2010
More
Hey guys,
Is there anyway to disable a toggle button and make it "greyed out"? I could just make it invisible but I think it would make more sense to the user if they could see that the button was not available rather than just having it disappear. I figured this would be pretty standard but I don't see it anywhere. Any help would be greatly appreciated.

Thanks,
Samuel Maskell
Rootstonian
26th February 2011, 03:22 AM   |  #2  
Guest
Thanks Meter: 0
 
n/a posts
What's the purpose of the button?

You could just leave it there and not process based on code in the Listener.
28th February 2011, 06:58 PM   |  #3  
OP Senior Member
Flag San Francisco
Thanks Meter: 45
 
463 posts
Join Date:Joined: Jan 2010
More
Yeah, I was thinking of just making it display a toast message or something
but it would really be nice if I could change the appearance of the button
maybe I can play around with changing the background a bit..
28th February 2011, 08:04 PM   |  #4  
Recognized Contributor
Flag Brighton IL
Thanks Meter: 552
 
1,667 posts
Join Date:Joined: Jul 2010
More
Why not just setEnabled(false); ?
28th February 2011, 08:04 PM   |  #5  
OP Senior Member
Flag San Francisco
Thanks Meter: 45
 
463 posts
Join Date:Joined: Jan 2010
More
so I tried just using setBackgroundColor(Color.DKGRAY) but that failed miserably..
I can use getBackground() to get a Drawable object
so I should be able to take that object and make it darker
and then use setBackgroundDrawable, right?
I'm just not too sure how to go about making that drawable darker..
28th February 2011, 08:23 PM   |  #6  
OP Senior Member
Flag San Francisco
Thanks Meter: 45
 
463 posts
Join Date:Joined: Jan 2010
More
Quote:
Originally Posted by Gene Poole

Why not just setEnabled(false); ?

Didn't see your post last time. I am using setEnabled(false), but this does not change the appearance of the button. How are users supposed to know that the button is disabled? They'll just press it and think that the application froze or something because nothing will happen. If I could make the button darker and disable it, I think people would get the idea that it is disabled and not just broken.

Thanks,
Sam
28th February 2011, 08:29 PM   |  #7  
OP Senior Member
Flag San Francisco
Thanks Meter: 45
 
463 posts
Join Date:Joined: Jan 2010
More
apparently the background isn't what I want to change. Not sure what I should be doing exactly..
Last edited by smaskell; 28th February 2011 at 08:38 PM.
28th February 2011, 09:12 PM   |  #8  
freekyfrogy's Avatar
Senior Member
Flag Virginia
Thanks Meter: 21
 
366 posts
Join Date:Joined: Aug 2009
More
have you tried toggle.setColorFilter(0xAARRGGBB, Mode.SRC_ATOP); ?

you'd need to find the correct #AARRGGBB code for a greyish color, but it should work.

EDIT: Ok, so after playing around with the settings a bit I found that this works pretty nicely for greying something out toggle.setColorFilter(0xA6A6A6A6, Mode.SRC_ATOP);
Last edited by freekyfrogy; 28th February 2011 at 09:17 PM.
The Following User Says Thank You to freekyfrogy For This Useful Post: [ View ]
28th February 2011, 09:30 PM   |  #9  
OP Senior Member
Flag San Francisco
Thanks Meter: 45
 
463 posts
Join Date:Joined: Jan 2010
More
ToggleButton doesn't seem to have a setColorFilter() class
did you do toggle.getBackground.setColorFilter() or something like that?
28th February 2011, 09:33 PM   |  #10  
freekyfrogy's Avatar
Senior Member
Flag Virginia
Thanks Meter: 21
 
366 posts
Join Date:Joined: Aug 2009
More
Actually, I was using setColorFilter on an ImageButton, that's probably why... sorry :P

Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes