我正在尝试创建一个游戏,在课程活动中我有一个优美的风景背景。我希望玩家在我的教程弹出式xml膨胀之前能看到这个背景一两秒钟。问题是,透明的弹出式xml和背景xml都会在活动初始化时立即出现。我是新手无法理解Android开发者主页上的解释。任何帮助将不胜感激。
package com.jibushi;
import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class LessonsShell extends Activity {
private View view;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.lessons);
final ViewGroup parent = (ViewGroup) findViewById(R.id.lessons_bg);
Thread splashTread = new Thread() {
@Override
public void run() {
try {
wait(1000);
} catch (InterruptedException e) {
} finally {
view();
}
}
private void view() {
// TODO Auto-generated method stub
view = LayoutInflater.from(getBaseContext()).inflate(
R.layout.lessons_dialog, null);
parent.addView(view);
}
};
splashTread.start();
}
}