我正在尝试为图像制作动画,这是我在 xml 文件中的代码
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false" >
<item android:drawable="@drawable/father11" android:duration="200" />
<item android:drawable="@drawable/father22" android:duration="200" />
<item android:drawable="@drawable/father33" android:duration="200" />
<item android:drawable="@drawable/father44" android:duration="200" />
<item android:drawable="@drawable/father55" android:duration="200" />
</animation-list>
但是在我的应用程序中,我必须在单击按钮时运行动画图像,但我收到了 sentax 错误
btn_father.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
SignImage = (ImageView) findViewById(R.id.Sign);
SignImage.setImageResource(R.drawable.fatherr);
lightsAnimation=(AnimationDrawable) SignImage.getDrawable();
}
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
lightsAnimation.start();
}
});
我在链接中阅读了这个句子,但不理解它“(如果可以很容易地用按钮或其他类型的输入开始)。用这个类替换 src 树中 main.java 文件中的主类”