public classAutoActivityextendsAppCompatActivity {
privateImageViewauto_image;
//图片数量
private inti=3;
//图片数组
private int[]image={
R.mipmap.mg5,R.mipmap.mg4,R.mipmap.mg3
};
@Override
protected voidonCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_auto);
initView();
}
Runnablerunnable=newRunnable() {
@Override
public voidrun() {
if(i>0){
i--;
auto_image.setScaleType(ImageView.ScaleType.CENTER_CROP);
auto_image.setImageResource(image[i]);
//耗时操作
auto_image.postDelayed(runnable,1500);
}
}
};
private voidinitView() {
auto_image= (ImageView) findViewById(R.id.auto_image);
//耗时开始
auto_image.post(runnable);
}