image show by timer android studio

Solutions on MaxInterview for image show by timer android studio by the best coders in the world

showing results for - "image show by timer android studio"
Fergus
03 Oct 2019
1public class MainActivity extends Activity {
2
3Random random = new Random();
4int max = 2;
5int min = 0;
6
7ImageView imageView;
8
9Integer[] image = { R.drawable.ic_launcher, R.drawable.tmp,R.drawable.android };
10
11@Override
12public void onCreate(Bundle savedInstanceState) {
13    super.onCreate(savedInstanceState);
14    setContentView(R.layout.splash);
15
16    int randomNumber = random.nextInt(max - min + 1) + min;
17
18    imageView = (ImageView) findViewById(R.id.img);
19
20    imageView.setImageResource(image[randomNumber]);
21
22    new Handler().postDelayed(new Runnable() {
23
24        @Override
25        public void run() {
26            Intent intent = new Intent(MainActivity.this, Act.class);
27            startActivity(intent);
28        }
29    }, 5000);
30  }
31}
32