【发布时间】:2013-05-26 19:47:43
【问题描述】:
我正在开发一个 android 应用程序,但似乎无法在主要活动之前启动启动画面,但在我所有其他应用程序上这都没问题
这可能是什么问题?代码没有问题。
package com.example.soundboardapp;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
public class splash extends Activity {
private long ms = 0;
private long splashTime = 2000;
private boolean splashActive = true;
private boolean paused = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.splash);
Thread mythread = new Thread() {
public void run() {
try {
while (splashActive && ms < splashTime) {
if (!paused)
ms = ms + 100;
sleep(100);
}
} catch (Exception e) {
} finally {
Intent intent = new Intent(splash.this, MainActivity.class);
finish();
startActivity(intent);
}
}
};
mythread.start();
}
}
有一个与代码对应的启动活动。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/intro22"
>
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center" >
</LinearLayout>
<ProgressBar
android:id="@+id/progressBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="184dp" />
</RelativeLayout>
可能是什么问题?
【问题讨论】:
-
cyrilmottier.com/2012/05/03/…。有些人不鼓励启动画面
-
你的启动画面也没有任何作用,你为什么要拥有它?
-
我寻求帮助以使其正常工作,而不是让别人告诉不要使用它...
-
请发布您的 AndroidManifest.xml。
-
@GeoffBolton 检查链接。使用处理程序的启动画面。stackoverflow.com/questions/16750059/…
标签: java android xml splash-screen