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
[email protected]

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

Reply via email to