我希望在5秒内中断启动画面并转到下一个活动。
new CountDownTimer(5000, 1000)
{
@Override
public void onTick(long millisUntilFinished) {}
@Override
public void onFinish()
{
Intent I = new Intent(Home.this, Welcome1.class);
startActivity(I);
}
}.start();
答案 0 :(得分:0)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
....
splashDelaey();
}
void splashDelaey(){
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent I = new Intent(Home.this, Welcome1.class);
I.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(I);
}
},5000);
}
答案 1 :(得分:0)
试试这个。希望它有帮助
Thread splashTread; //Declare this class level variable
splashTread = new Thread() {
@Override
public void run() {
try {
synchronized (this) {
wait(900);
}
} catch (InterruptedException e) {
} finally {
Intent i = new Intent();
i.setClass(Home.this,Welcome1.class);
startActivity(i);
}
}
};
splashTread.start();
答案 2 :(得分:0)
这项工作很好
Thread background = new Thread() {
public void run() {
try {
// Thread will sleep for 5 seconds
sleep(3000);
// After 5 seconds redirect to another intent
Intent i = new Intent(getBaseContext(), Welcome1.class);
startSpecificActivity(i);
//Remove activity
finish();
} catch (Exception e) {
e.printStackTrace();
}
}
};
// start thread
background.start();
答案 3 :(得分:0)
public class Caracteristic
{
#region Properties
public int Id { get; set; }
[Required]
[MaxLength(50)]
public string Name { get; set; }
public string Description { get; set; }
public int CaracteristicGroupId { get; set; }
public virtual CaracteristicGroup Group { get; set; }
#endregion
}
检索布局的根视图,并在其上注册ClickListener。在同一个对象上,您可以使用findViewById
发布Runnable
。如果按屏幕,假设您的布局占据整个屏幕,则会调用postDelayed
。在那里,您可以从View的处理程序中删除runnable并启动新的onClick
。 E.g。
Activity
答案 4 :(得分:0)
最后我得到了答案。我所做的就是添加了这段代码
public boolean onTouchEvent(MotionEvent event){
boolean defaultResult = super.onTouchEvent(event);
switch (event.getAction()){
case MotionEvent.ACTION_DOWN:
Intent intent = new Intent(Home.this, Welcome1.class);
startActivity(intent);
break;
}
return defaultResult;