Hi, I am trying to use the LevelListDrawable class in order to control a sequence of images for a timer. The problem that I am having is that the setLevel() method is having no effect on the displayed image. The only image that is displayed in the UI is the first image in the list. According to documentation:
[Setting the level value of the object with setLevel(int) will load the image with the next greater or equal value assigned to its max attribute.] The documentation also states: [With this XML saved into the res/drawable/ folder of the project, it can be referenced as the drawable for an ImageView. The default image is the first in the list. It can then be changed to one of the other levels with setImageLevel(int).] I am a bit confused as to whether I need to call setLevel() on the LevelListDrawable object, or if I need to call setImageLevel() on an ImageView object that references the LevelListDrawable, or if I need to do both. I have explored each of these options but none of which caused the displayed image to change. My xml file (seconds.xml) that describes the behavior of the LevelListDrawable is as follows: <?xml version="1.0" encoding="utf-8"?> <level-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:maxLevel="9" android:drawable="@drawable/digit9" /> <item android:maxLevel="8" android:drawable="@drawable/digit8" /> <item android:maxLevel="7" android:drawable="@drawable/digit7" /> <item android:maxLevel="6" android:drawable="@drawable/digit6" /> <item android:maxLevel="5" android:drawable="@drawable/digit5" /> <item android:maxLevel="4" android:drawable="@drawable/digit4" /> <item android:maxLevel="3" android:drawable="@drawable/digit3" /> <item android:maxLevel="2" android:drawable="@drawable/digit2" /> <item android:maxLevel="1" android:drawable="@drawable/digit1" /> <item android:maxLevel="0" android:drawable="@drawable/digit0" /> </level-list> My main activity is setting up the ImageView object is currently setup like this: public void onCreate(Bundle savedInstanceBundle) { LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); ... ImageView m_secondsView = new ImageView(this); m_secondsView.setImageResource(R.drawable.seconds); layout.addView(m_secondsView); m_secondsView.setImageLevel(4); // for testing purposes let's try to change the UI m_oneSecondView.invalidate(); ... setContentView(layout); } I assume I am missing some important piece of how this class is supposed to be used but haven't been able to figure it out yet. Any help would be much appreciated. Thanks --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---