我正在使用 eclipse adt 开发我的第一个 android 应用程序。我成功制作了启动画面,但我想显示加载动画。我有以下代码:
package com.sunil.splash;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
public class Splash extends Activity {
private long ms=0;
private long splashTime=2000;
private boolean splashActive = true;
private boolean paused=false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Hides the titlebar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.splash);
Thread mythread = new Thread() {
public void run() {
try {
while (splashActive && ms < splashTime) {
if(!paused)
ms=ms+100;
sleep(100);
}
} catch(Exception e) {}
finally {
Intent intent = new Intent(Splash.this, Home.class);
startActivity(intent);
}
}
};
mythread.start();
}
}
你能帮我解决这个问题吗?