Drawable is not drawn after setDrawableByLayerId

by tt6 » Thu, 04 Feb 2010 05:50:29 GMT


Sponsored Links
 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!

--



Other Threads

1. Writing Current Time

Hi All,

In my application I will be writing messages to a text file. When I am
writing the messages I also want to include the time in it.

How do i write in the current date and time? Must I use Calendar now =
Calendar.getInstance() ?

Thanks In Advance,
Perumal

-- 

2. Can we release an updated version of app with lower min sdk?



We have an app thats running on 1.6 and higher but we want it to be able to run on 1.5 also. So I tested the app with 1.5 and everything works fine. So if I want to release this app can I release it as an update for my older app with just changing <uses-sdk android:minSdkVersion="4" /> to <uses-sdk android:minSdkVersion="3" />? Will there be any problems if I do so?
We did that with our app it seems to work fine. Michael --

3. Can we release an updated version of app with lower min sdk?

4. wpa_driver_priv_driver_cmd failed

5. Setting manual buat email yahoo....

6. AlarmManager - Listening to Alarms set/cancel method

7. AlarmManager - Listening to Alarms set/cancel method