为什么图片切换的时间间隔不一样呢,有的图片之间时间短,有的时间很长,代码和视频一样啊感觉????
public class MainActivity extends AppCompatActivity {
private TextView mTextView;
private Handler mHandler = new Handler();
private ImageView mImageView;
private int index = 0;
private MyRunnable myRunnable = new MyRunnable();
private int[] id = {R.drawable.hehe1,R.drawable.hehe2,R.drawable.hehe3};
public class MyRunnable implements Runnable{
@Override
public void run() {
index++;
index = index%3;
mImageView.setImageResource(id[index]);
mHandler.postDelayed(myRunnable,2000);
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mTextView = (TextView) findViewById(R.id.tv_show);
mImageView = (ImageView) findViewById(R.id.iv_show);
mHandler.postDelayed(myRunnable,2000);
}
}