我正在寻找示例代码,我的 xml 很好,我想在活动开始时立即开始动画,而不是按任何东西
import android.app.Activity;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.widget.ImageView;
public class AnimationActivity extends Activity
{
ImageView genie;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
genie = (ImageView)findViewById(R.id.genieout);
genie.setBackgroundResource(R.drawable.genieani);
genie.post(new Runnable() {
@Override
public void run() {
AnimationDrawable genieout =
(AnimationDrawable) genie.getBackground();
genieout.start();
}
});
}