img = (ImageView) findViewById(R.id.img);
ad=new AnimationDrawable();
ad.addFrame(getResources().getDrawable(R.drawable.img0), 50);
ad.addFrame(getResources().getDrawable(R.drawable.img1), 50);
ad.addFrame(getResources().getDrawable(R.drawable.img2), 50);
ad.addFrame(getResources().getDrawable(R.drawable.img3), 50);
//关联 img.setBackgroundDrawable(ad); ad.setOneShot(false);
public void start(View view){ ad.start(); } public void stop(View view){ if(ad.isRunning()){ ad.stop(); }
转载请注明原文地址: https://ju.6miu.com/read-1300829.html