使用 Android Studio,我想在我的应用程序中放入一个启动屏幕加载 6 秒,然后再打开游戏的活动。我把java代码和xml都放了,但是当我启动设备时,启动画面没有出现。我不明白错误是什么。你能帮帮我吗?
这是我的 SplashScreenActivity.java
public class SplashScreenActivity extends Activity {
private final int SPLASH_DISPLAY_LENGHT = 6000;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.splash);
/* New Handler to start the Menu-Activity
* and close this Splash-Screen after some seconds.*/
new Handler().postDelayed(new Runnable(){
@Override
public void run() {
/* Create an Intent that will start the Menu-Activity. */
Intent mainIntent = new Intent(SplashScreenActivity.this,Menu.class);
SplashScreenActivity.this.startActivity(mainIntent);
SplashScreenActivity.this.finish();
}
}, SPLASH_DISPLAY_LENGHT);
}
}
和文件 xml :
<RelativeLayout
android:id="@+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:gravity="center"
android:background="#ff000000">
<TextView android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:textStyle="bold"
android:textColor="#fff"
android:text="LOADING..."
android:layout_marginTop="250dp"
android:layout_marginLeft="30dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="500dp"
android:textColor="#ffffffff"
android:text=""
android:gravity="center"/>