我目前正在尝试闪烁三秒钟的启动画面,然后再进行第一个活动。但是,一旦启动画面出现,它就不会移动到下一个“主菜单”屏幕。
package edu.wcu.lect4;
import android.os.Bundle;
import android.os.Handler;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
public class MainMenu extends Activity {
final int PAUSE = 3000;
Handler handler;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_menu);
}
protected void onStart() {
super.onStart();
handler = new Handler();
handler.postDelayed(r, PAUSE);
}//end on start}
final Runnable r = new Runnable()
{
public void run()
{
goToNextScreen();
finish();
}
};
private void goToNextScreen()
{
Intent menu = new Intent(this, edu.wcu.lect4.MainMenu.class);
this.startActivity(menu);
}
}
此外,这里是 XML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/splashscrn"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainMenu" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="Press me" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="60dp"
android:text="MAIN MENU" />
我究竟做错了什么?