Post Reply

make a toggle button "greyed out"

OP smaskell

26th February 2011, 02: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, 02: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, 05: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, 07:04 PM   |  #4  
Recognized Contributor
Flag Brighton IL
Thanks Meter: 551
 
1,667 posts
Join Date:Joined: Jul 2010
More
Why not just setEnabled(false); ?
28th February 2011, 07: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, 07: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, 07: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 07:38 PM.
28th February 2011, 08: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 08:17 PM.
The Following User Says Thank You to freekyfrogy For This Useful Post: [ View ]
28th February 2011, 08: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, 08: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


Top Threads in Android Software Development by ThreadRank