Introducing XDA:DevCon – A Conference For Developers By Developers
XDA Developers Android and Mobile Development Forum
Forgot your password?
 
Post Reply+
Tip us?
 
smaskell
Old
#1  
Senior Member - OP
Thanks Meter 44
Posts: 459
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  
Senior Member
Thanks Meter 26
Posts: 298
Join Date: Dec 2010
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 44
Posts: 459
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 513
Posts: 1,624
Join Date: Jul 2010
Location: Brighton IL
Why not just setEnabled(false); ?
 
smaskell
Old
#5  
Senior Member - OP
Thanks Meter 44
Posts: 459
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 44
Posts: 459
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 44
Posts: 459
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: 361
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 44
Posts: 459
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: 361
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.

 
Post Reply+
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Go to top of page...

XDA PORTAL POSTS

Learn to Edit Graphics for your Development Work

The importance of good and appropriate graphics for your development work is undeniable. Be … more

Tasker Alternative: AutomateIt, Automates Your Device Tasks – XDA Developer TV

XDA Developer TV Producer Kevin wants to help make your … more

Preventing App Piracy: Join the Discussion

The topic of piracy is always a touchy subject, but I feel that the grass roots style of Android … more

Jolla Sailfish OS Flagship Device Makes First Appearance

Given the amount of coverage that Android receives around here, you could almost be … more