Jonathan Pryor-2 wrote:
> 
> On Aug 23, 2011, at 3:50 PM, chobo2 wrote:
>> // this seems to be how do it in android
>> ShapeDrawable bgShape = (ShapeDrawable )btn.getBackground();
>> bgShape.getPaint().setColor(Color.BLACK);
>> 
>> 
>> I tried
>> 
>>    ShapeDrawable bgShape = (ShapeDrawable)
>> Resources.GetDrawable(Resource.Drawable.danger_box);
>>            bgShape.Paint.Color = Resource.Color.test;
> 
> Those don't seem to be equivalent. :-)
> 
> The "proper" equivalent would be:
> 
>       Button btn = GetSomeButton ();
>       ShapeDrawable bgShape = (ShapeDrawable) btn.Background;
>       bg.Paint.Color = Android.Graphics.Color.Black.ToArgb ();
> 
> Note in particular that Color.BLACK is an `int`, but it's not a
> Resource-backed int, it's a packed RGBA `int`. (Such is the "joy" of
> `int`s...)
> 
>> but it crashes on the first line(does not really seem to give a error).
> 
> As for your crash on Resources.GetDrawable(), I don't know. Is there a
> stack trace printed in the Android Debug Log? (Try with 1.0.3 if
> possible.)
> 
> Thanks,
>  - Jon
> 
> _______________________________________________
> Monodroid mailing list
> Monodroid@lists.ximian.com
> 
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid
> 

I guess I copied the wrong one I meant this one

ShapeDrawable sd = (ShapeDrawable)
getResources().getDrawable(R.drawable.color_box);
       sd.getPaint().setColor(0x00000000);

Well What happens if I want to use a color from a resource file? Do I still
use the Resource and get's it's id?

--
View this message in context: 
http://mono-for-android.1047100.n5.nabble.com/How-to-change-shapes-color-dynamically-tp4728020p4731913.html
Sent from the Mono for Android mailing list archive at Nabble.com.
_______________________________________________
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

Reply via email to