我在Android上是一个完整的新手,我正在尝试按照在线教程添加启动画面:http://www.slideshare.net/YasmineSherif91/android-application-how-to-add-a-splash-screen-with-timer-tutorial-4
我现在在令牌,错位的构造上得到错误语法错误,我不能为我的生活解决原因。任何帮助非常感谢。谢谢 我的代码在
之下 protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash_screen);
Thread logoTimer - new Thread (){
public void run(){
try{
int logoTimer = 0;
while (logoTimer<5000){
sleep(100);
logoTimer-=logoTimer+100;
}
startActivity(new Intent("com.nrobson.mot2.Clearscreen"))
)
finally(
finish());
}
};
}
logoTimer.start();
答案 0 :(得分:3)
你有很多语法错误。尝试使用:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash_screen);
Thread logoTimer = new Thread() {
public void run() {
try {
int logoTimer = 0;
while (logoTimer < 5000) {
try {
sleep(100);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
logoTimer -= logoTimer + 100;
}
startActivity(new Intent("com.nrobson.mot2.Clearscreen"));
} finally {
finish();
}
}
};
logoTimer.start();
}
这里有一个(可能不完整的)错误列表:
-
代替=
logoTimer.start();
在您的方法正文之外(
和)
代替finally
阻止代替{
和}
try-catch
InterruptedException
阻止startActivity(new Intent("com.nrobson.mot2.Clearscreen"))
另外,该行:
logoTimer -= logoTimer + 100;
转换为:
logoTimer = logoTimer - (logoTimer + 100);
你确定要的吗?