我爲新到Android編程 我試圖開發一個簡單的程序中出現空白屏幕後 和5秒後,我的主要活動開始 但問題是當我啓動應用程序後5 - 6秒它顯示錯誤 我編程的XML和我的佈局是正確的 我的應用程序平臺是2.2 froyo 和我運行它在2.3.6 主要活動是加一減一活動 請告訴我它在很多程序中發生了什麼事無法在Android應用程序打開我的下一個屏幕5秒鐘
在此主要活動開始後第一個活動的代碼小號
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.splash); //splash is a blank activity which changes after 5 sec
Thread timer = new Thread() {
public void run(){
try{
sleep(5000);
}catch(InterruptedException e){
e.printStackTrace();
}finally{
Intent newtask = new Intent("com.example.newscreentask.newacivity");
startActivity( newtask);
}
}
};
timer.start();
}}
你必須提供你的代碼和logcat輸出。 – FWeigl
試試Intent newTask = new Intent(MainActivity.this,newActivity.class); –
提示:除非您的應用需要在運行之前下載/讀取一些初步數據,否則通常不推薦使用splashscreen。 –