📜  计时器 android studio 显示的图像 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:05.259000             🧑  作者: Mango

代码示例1
public class MainActivity extends Activity {

Random random = new Random();
int max = 2;
int min = 0;

ImageView imageView;

Integer[] image = { R.drawable.ic_launcher, R.drawable.tmp,R.drawable.android };

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splash);

    int randomNumber = random.nextInt(max - min + 1) + min;

    imageView = (ImageView) findViewById(R.id.img);

    imageView.setImageResource(image[randomNumber]);

    new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            Intent intent = new Intent(MainActivity.this, Act.class);
            startActivity(intent);
        }
    }, 5000);
  }
}