public class MainActivity extends AppCompatActivity{
private ImageView rea;
private int time=3;
private Handler handler=new Handler(){
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
if (msg.what==0){
if (time>0){
time--;
text_time.setText(time+"s");
handler.sendEmptyMessageDelayed(0,1000);
}else {
Intent intent = new Intent(MainActivity.this, SecondActivity.class);
startActivity(intent);
finish();
}
}
}
};
private TextView text_time;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
rea = findViewById(R.id.rea);
text_time = findViewById(R.id.text_time);
//RotateAnimation animation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5F, Animation.RELATIVE_TO_SELF, 0.5F);
//animation.setDuration(4000);
//rea.startAnimation(animation);
AlphaAnimation alphaAnimation = new AlphaAnimation(0, 1);
alphaAnimation.setDuration(4000);
rea.startAnimation(alphaAnimation);
handler.sendEmptyMessageDelayed(0,1000);
}
}