Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion ABS menu icons: setEnabled(false)

Date: Mon, 4 Jun 2012 09:08:29 -0700 (PDT)
From: Oleg Vaskevich <theol...@gmail.com>
To: actionbarsherlock@googlegroups.com
Message-Id: <a125814b-be4c-4328-9eaa-294c23096a0d@googlegroups.com>
In-Reply-To: <5dd61665-e44d-470b-9126-aebbe2dd9f17@googlegroups.com>
References: <7d3ded77-0fba-4f0b-a3f4-aa2c7f2c93f1@googlegroups.com>
 <5dd61665-e44d-470b-9126-aebbe2dd9f17@googlegroups.com>
Subject: Re: ABS menu icons: setEnabled(false)
MIME-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_45_1453234.1338826109227"

------=_Part_45_1453234.1338826109227
Content-Type: multipart/alternative; 
	boundary="----=_Part_46_30437037.1338826109227"

------=_Part_46_30437037.1338826109227
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

That works great - thank you!

On Monday, June 4, 2012 11:51:02 AM UTC-4, S=C3=A9rgio Faria wrote:
>
> I use a color filter, I've no idea how close the effect is to the "native=
=20
> filter", but looks great.
>
>     /**
>      * Mutates and applies a filter that converts the given drawable to a=
=20
> Gray image. This method
>      * may be used to simulate the color of disable icons in Honeycomb's=
=20
> ActionBar.
>      *=20
>      * @return a mutated version of the given drawable with a color filte=
r=20
> applied.
>      */
>     public static Drawable convertDrawableToGrayScale(Drawable drawable) =
{
>         if (drawable =3D=3D null) {
>             return null;
>         }
>
>         Drawable res =3D drawable.mutate();
>         res.setColorFilter(Color.GRAY, PorterDuff.Mode.SRC_IN);
>         return res;
>     }
>
> Segunda-feira, 4 de Junho de 2012 7:48:03 UTC+1, Oleg Vaskevich escreveu:
>>
>> In my app, I need to disable menu items depending on the state of a=20
>> database. I do this with SherlockActivity.supportInvalidateOptionsMenu()=
 and=20
>> calling setEnabled(false) on the menu items I want to disable. While=20
>> this does disable the text, the icons remain the same - they are not=20
>> "grayed out" or anything.
>>
>> Is this intended behavior? If not, I'd still like to give the icons a=20
>> disabled look. Looks like there are two options:
>>
>>
>>    1. Use a StateListDrawable to set disabled versions of icon files
>>    2. Look to see how Android makes icons disabled on previous versions.=
=20
>>    This could be possibly be done using setAlpha() or setColorFilter(...=
)
>>
>> Any suggestions (esp. regarding where to look for #2 - MenuItem.java?=20
>> That's just an interface) would be appreciated.
>>
>
------=_Part_46_30437037.1338826109227
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

That works great - thank you!<br><br>On Monday, June 4, 2012 11:51:02 AM UT=
C-4, S=C3=A9rgio Faria wrote:<blockquote class=3D"gmail_quote" style=3D"mar=
gin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">I=
 use a color filter, I've no idea how close the effect is to the "native fi=
lter", but looks great.<br><br>&nbsp;&nbsp;&nbsp; /**<br>&nbsp;&nbsp;&nbsp;=
&nbsp; * Mutates and applies a filter that converts the given drawable to a=
 Gray image. This method<br>&nbsp;&nbsp;&nbsp;&nbsp; * may be used to simul=
ate the color of disable icons in Honeycomb's ActionBar.<br>&nbsp;&nbsp;&nb=
sp;&nbsp; * <br>&nbsp;&nbsp;&nbsp;&nbsp; * @return a mutated version of the=
 given drawable with a color filter applied.<br>&nbsp;&nbsp;&nbsp;&nbsp; */=
<br>&nbsp;&nbsp;&nbsp; public static Drawable convertDrawableToGrayScale(<w=
br>Drawable drawable) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (d=
rawable =3D=3D null) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp; return null;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
; }<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Drawable res =3D draw=
able.mutate();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; res.setColorFi=
lter(Color.GRAY, PorterDuff.Mode.SRC_IN);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp; return res;<br>&nbsp;&nbsp;&nbsp; }<br><br>Segunda-feira, 4 de=
 Junho de 2012 7:48:03 UTC+1, Oleg Vaskevich escreveu:<blockquote class=3D"=
gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid=
;padding-left:1ex">In my app, I need to disable menu items depending on the=
 state of a database. I do this with <font face=3D"courier new, monospace">=
SherlockActivity.<wbr>supportInvalidateOptionsMenu()</font><wbr>&nbsp;and c=
alling <font face=3D"courier new, monospace">setEnabled(false)</font> on th=
e menu items I want to disable. While this does disable the text, the icons=
 remain the same - they are not "grayed out" or anything.<div><br></div><di=
v>Is this intended behavior? If not, I'd still like to give the icons a dis=
abled look. Looks like there are two options:</div><div><br></div><div><ol>=
<li><span style=3D"line-height:normal">Use a StateListDrawable to set disab=
led versions of icon files</span></li><li><span style=3D"line-height:normal=
">Look to see how Android makes icons disabled on previous versions. This c=
ould be possibly be done using <font face=3D"courier new, monospace">setAlp=
ha()</font> or <font face=3D"courier new, monospace">setColorFilter(...)</f=
ont></span></li></ol><div>Any suggestions (esp. regarding where to look for=
 #2 - MenuItem.java? That's just an interface) would be appreciated.</div><=
/div></blockquote></blockquote>
------=_Part_46_30437037.1338826109227--

------=_Part_45_1453234.1338826109227--