Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,732,970 Members 49,078 Now Online
XDA Developers Android and Mobile Development Forum

make a toggle button "greyed out"

Tip us?
 
smaskell
Old
#1  
Senior Member - OP
Thanks Meter 45
Posts: 461
Join Date: Jan 2010
Location: Victoria, BC, Canada
Default make a toggle button "greyed out"

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 Old
#2  
Guest
Thanks Meter
Posts: n/a
What's the purpose of the button?

You could just leave it there and not process based on code in the Listener.
 
smaskell
Old
#3  
Senior Member - OP
Thanks Meter 45
Posts: 461
Join Date: Jan 2010
Location: Victoria, BC, Canada
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..
 
Gene Poole
Old
#4  
Recognized Contributor
Thanks Meter 551
Posts: 1,667
Join Date: Jul 2010
Location: Brighton IL
Why not just setEnabled(false); ?
 
smaskell
Old
#5  
Senior Member - OP
Thanks Meter 45
Posts: 461
Join Date: Jan 2010
Location: Victoria, BC, Canada
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..
 
smaskell
Old
#6  
Senior Member - OP
Thanks Meter 45
Posts: 461
Join Date: Jan 2010
Location: Victoria, BC, Canada
Quote:
Originally Posted by Gene Poole View Post
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
 
smaskell
Old
(Last edited by smaskell; 28th February 2011 at 07:38 PM.)
#7  
Senior Member - OP
Thanks Meter 45
Posts: 461
Join Date: Jan 2010
Location: Victoria, BC, Canada
apparently the background isn't what I want to change. Not sure what I should be doing exactly..
 
freekyfrogy
Old
(Last edited by freekyfrogy; 28th February 2011 at 08:17 PM.)
#8  
freekyfrogy's Avatar
Senior Member
Thanks Meter 18
Posts: 363
Join Date: Aug 2009
Location: Virginia
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);
Make sure to click the "Thanks" button if you like what I do! It helps my ego

As of 4/1/2013:

Current Phone: Galaxy Nexus
ROM: Paranoid Android

Current Tablet: Asus TransformerTF300
ROM: Paranoid Android


follow me on twitter and I'll give you a cookie!

Donate here if you feel the urge, help me to have a soda during my class breaks haha.
The Following User Says Thank You to freekyfrogy For This Useful Post: [ Click to Expand ]
 
smaskell
Old
#9  
Senior Member - OP
Thanks Meter 45
Posts: 461
Join Date: Jan 2010
Location: Victoria, BC, Canada
ToggleButton doesn't seem to have a setColorFilter() class
did you do toggle.getBackground.setColorFilter() or something like that?
 
freekyfrogy
Old
#10  
freekyfrogy's Avatar
Senior Member
Thanks Meter 18
Posts: 363
Join Date: Aug 2009
Location: Virginia
Actually, I was using setColorFilter on an ImageButton, that's probably why... sorry :P
Make sure to click the "Thanks" button if you like what I do! It helps my ego

As of 4/1/2013:

Current Phone: Galaxy Nexus
ROM: Paranoid Android

Current Tablet: Asus TransformerTF300
ROM: Paranoid Android


follow me on twitter and I'll give you a cookie!

Donate here if you feel the urge, help me to have a soda during my class breaks haha.

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


XDA PORTAL POSTS

Rir Yourself Charging Annoyances with No Wake on Charge Xposed Module

Almost every OEM has skinned and otherwise modifiedAndroid to suit its … more

Run, Jump, and Shoot in Tales of Ciaxia

There are certain types of games that have become paramount of the portable gaming world. As we have … more