Splash activity
public static final long TIME = 3000;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.logo);
Protocol.getInstance(this);
Thread welcomeThread = new Thread() {
@Override
public void run() {
try {
sleep(TIME);
} catch (Exception e) {
Log.e(getClass().getName(), e.toString());
} finally {
startActivity(new Intent(LaunchScreen.this,MainScreen.class));
finish();
}
}
};
welcomeThread.start();
}
logo.xml file:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="right" > <ImageView android:id="@+id/logo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/logo" android:layout_centerInParent="true" > </ImageView> </RelativeLayout>
in AndroidManifest :
<activity android:name=".LaunchScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainScreen" android:label="@string/app_name" ></activity>
from http://stackoverflow.com/questions/8642730/splash-screen-in-android-application
本文介绍了一个简单的Android启动屏(Splash Screen)实现方案。通过设置欢迎界面的延时跳转,展示应用Logo,并在指定时间后自动导航到主屏幕。代码示例展示了如何使用线程睡眠来控制显示时间。
3481

被折叠的 条评论
为什么被折叠?



