我设计了一个带有按钮的启动画面。Java代码如下。启动画面的布局包含一些带有动画的文本和名为跳过的启动画面的按钮。当用户按下按钮时,闪屏必须立即停止并打开下一个活动。但是当我打开启动画面并按下跳过按钮时,下一个活动会打开,但在启动画面必须运行的持续时间结束后,活动会再次打开。当用户按下跳过按钮时如何停止启动屏幕?
public class Qz1 extends Activity {
TextView a;
TextView b;
TextView c;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_qz1);
a =(TextView)findViewById(R.id.roundOnea22);
a.startAnimation(AnimationUtils.loadAnimation(Qz1.this, R.anim.anim_slide_in_left));
b =(TextView)findViewById(R.id.roundOneb);
b.startAnimation(AnimationUtils.loadAnimation(Qz1.this, R.anim.anim_slide_in_right));
c =(TextView)findViewById(R.id.roundme);
c.startAnimation(AnimationUtils.loadAnimation(Qz1.this, R.anim.anim_slide_in_left));
Thread thread = new Thread(){
@Override
public void run() {
// TODO Auto-generated method stub
try{
sleep(3200);
startActivity(new Intent(getApplicationContext(), Qone.class));
} catch (InterruptedException e){
e.printStackTrace();
}
}
};
thread.start();
}
public void round1(View v){
Intent i = new Intent(Qz1.this, Qone.class);
startActivity(i);
}
}