导航欢迎主程序public class WelcomeAct extends Activity { private boolean isFirstIn = false; private static final int TIME = 2000; private static final int GO_HOME = 1000; private static final int GO_GUIDE = 1001; private Handler mHandler = new Handler(){ public void handleMessage(android.os.Message msg) { switch (msg.what) { case GO_HOME: goHome(); break; case GO_GUIDE: goGuide(); break; } }; }; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.welcome); init(); } private void init(){ SharedPreferences perPreferences = getSharedPreferences("jike", MODE_PRIVATE); isFirstIn = perPreferences.getBoolean("isFirstIn", true); if (!isFirstIn) { mHandler.sendEmptyMessageDelayed(GO_HOME, TIME); }else{ mHandler.sendEmptyMessageDelayed(GO_GUIDE, TIME); SharedPreferences.Editor editor = perPreferences.edit(); editor.putBoolean("isFirstIn", false); editor.commit(); } } private void goHome(){ Intent i = new Intent(WelcomeAct.this,MainActivity.class); startActivity(i); finish(); } private void goGuide(){ Intent i = new Intent(WelcomeAct.this,Guide.class); startActivity(i); finish(); }}布局文件<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <ImageView android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/welcome_android" /></LinearLayout>AndroidMainfirst配置<activity android:name=".WelcomeAct"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter></activity>为什么程序启动时先白屏一会,然后在跳出欢迎界面的图片?
2 回答
蜂之谷
TA贡献564条经验 获得超863个赞
在样式文件中添加
<item name="android:windowIsTranslucent">true</item>
<style name="WelcomeTheme" parent="@android:style/Theme.NoTitleBar.Fullscreen"> <item name="android:windowIsTranslucent">true</item> </style>
<activity android:name=".WelcomeAct" android:theme="@style/WelcomeTheme"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
- 2 回答
- 0 关注
- 2241 浏览
添加回答
举报
0/150
提交
取消