找回密码
 注册
查看: 5988|回复: 0

Android欢迎界面实现源代码

[复制链接]
发表于 2013-10-3 20:39:32 | 显示全部楼层 |阅读模式
应用启动的时候,一般会有一个欢迎界面,是如何实现的呢?其实很简单:

  1. public class WelComeActivity extends Activity {
  2.     /** Called when the activity is first created. */
  3.     @Override
  4.     public void onCreate(Bundle savedInstanceState) {
  5.         super.onCreate(savedInstanceState);
  6.         setContentView(R.layout.welcome);
  7.         Start();
  8.     }
  9.    
  10.     public void Start() {
  11.                 new Thread() {
  12.                         public void run() {
  13.                                 try {
  14.                                         Thread.sleep(2500);
  15.                                 } catch (InterruptedException e) {
  16.                                         e.printStackTrace();
  17.                                 }
  18.                                 Intent intent = new Intent();
  19.                                 intent.setClass(WelComeActivity.this, LoginActivity.class);
  20.                                 startActivity(intent);
  21.                                 finish();
  22.                         }
  23.                 }.start();
  24.         }
  25. }
复制代码
布局文件:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3.     android:orientation="vertical"
  4.     android:layout_width="fill_parent"
  5.     android:layout_height="fill_parent"
  6.     android:background="@drawable/logo"
  7.     >
  8. </LinearLayout>
复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|微酷论坛

GMT+8, 2025-12-26 02:15 , Processed in 0.024869 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表