LaunchActivity未显示正确的布局

时间:2015-01-08 10:24:28

标签: android launch

我有一个具有此布局的启动活动,它仅显示中心的图像。

但是,只显示空白黑页,然后跳转到目标类。

问题是启动活动没有显示在activity_launch.xml中......问题是什么?

activity_launch.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".app.LaunchActivity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center_vertical|center_horizontal"
android:background="#0064B0">

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/logo_property_finder" />
</LinearLayout>

的java:

public class LaunchActivity extends BaseActivity {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_launch);

    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    } finally {
        Intent intent = new Intent(this, HomeActivity.class);
        startActivity(intent);
        this.finish();
    }
}
}

这是LaunchActivity的清单: 清单:

<application
    android:name=".app.BaseApplication"
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/MyTheme">

    <!-- App Pages -->
    <activity
        android:name=".app.LaunchActivity"
        android:label="@string/app_name"
        android:launchMode="singleTop"
        android:screenOrientation="portrait"
        android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
... Other activities
</application>

MyTheme的:

<style name="MyTheme" parent="@android:style/Theme.Holo.Light">
    <item name="android:homeAsUpIndicator">@drawable/button_back</item>
    <item name="android:actionBarStyle">@style/MyActionBar</item>
</style>

1 个答案:

答案 0 :(得分:2)

在LaunchActivity的onCreate()方法中尝试这样。

Handler handler=new Handler();
    handler.postDelayed(new Runnable() {

        @Override
        public void run() {
            Intent intent=new Intent(LaunchActivity.this, HomeActivity.class);
            startActivity(intent);
            finish();
        }
    }, 1000);