Since this hits the top of my search list for this issue, I thought I would 
give this thread an answer...

>From what I can tell, LayerDrawable. setDrawableByLayerId is useless on 
lots of devices (strangely works well on Nexus S).  I suggest building a 
new LayerDrawable instead.

On Wednesday, February 3, 2010 1:06:12 PM UTC-6, tt6 wrote:
>
>
> Hi,
>
> I'm having a problem with displaying a drawable. I have a ImageButton
> and a LayerDrawable. I set up an array of Drawable that has one
> Drawable for the background (index 0) and one for the image (index 1).
> The button would display different background on different states of
> the button. What I've done is when the button state changes I replace
> the background Drawable like:
>
>           elements[0] = <background drawable object>
>           elements[1] = <image drawable object>
>           layers = new LayerDrawable(elements);
>           layers.setId(0, 0);
>           layers.setId(1, 1);
>         ...
>
>           LayerDrawable ld = (LayerDrawable)button.getDrawable();
>           boolean result = ld.setDrawableByLayerId(0, <new
> backgroundDrawable>);
>         ...
>
> The problem is the initial old background is gone but the new one is
> not displayed. What have I done wrong or missed?
>
> Thank you!
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to