我目前想要使用Android的系统Spinners,它位于..\sdk\platforms\android-19\data\res\
我目前有.png文件示例spinner_white_48.png
和动画xml progress_medium_holo.xml
:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<rotate
android:drawable="@drawable/spinner_48_outer_holo"
android:pivotX="50%"
android:pivotY="50%"
android:fromDegrees="0"
android:toDegrees="1080" />
</item>
<item>
<rotate
android:drawable="@drawable/spinner_48_inner_holo"
android:pivotX="50%"
android:pivotY="50%"
android:fromDegrees="720"
android:toDegrees="0" />
</item>
</layer-list>
以下不起作用:
// Load the ImageView that will host the animation and
// set its background to our AnimationDrawable XML resource.
ImageView img = new ImageView(context);
img.setBackgroundResource(my.package.R.drawable.progress_medium_holo);
// Get the background, which has been compiled to an AnimationDrawable object.
AnimationDrawable frameAnimation = (AnimationDrawable) img.getBackground();
// Start the animation (looped playback by default).
frameAnimation.start();
我现在正在接收错误:
12-05 23:31:15.731: E/AndroidRuntime(30685): java.lang.ClassCastException: android.graphics.drawable.LayerDrawable cannot be cast to android.graphics.drawable.AnimationDrawable
我找不到有关如何以编程方式实现这些内容的任何信息。