zoukankan      html  css  js  c++  java
  • [转]Android启动画面实现

    本文转自:http://www.cnblogs.com/dawei/archive/2010/04/29/1724044.html

    在应用程序中经常用到启动画面,会启动一个后台线程为主程序的运行准备资源。

    Android要实现启动画面可以这样做:

    这是splash.xml布局文件的代码

    代码
    <LinearLayout
      
    xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_height
    ="fill_parent" android:layout_width="fill_parent" android:orientation="vertical">
    <ImageView android:layout_height="fill_parent" android:layout_width="fill_parent" android:scaleType="fitCenter" android:src="@drawable/splash"></ImageView>
    </LinearLayout>

     放一个ImageView加载启动画面图片

     SplashActivity作为主视图启动

    代码
    /** Called when the activity is first created. */
        @Override
        
    public void onCreate(Bundle savedInstanceState) {
            
    super.onCreate(savedInstanceState);
            setContentView(R.layout.splash);
            Handler x 
    = new Handler();
            x.postDelayed(
    new splashhandler(), 2000);
            
        }
        
    class splashhandler implements Runnable{

            
    public void run() {
                startActivity(
    new Intent(getApplication(),MainActivity.class));
                SplashActivity.
    this.finish();
            }
            
        }

    加载后使用Handler的postDelayed方法,2秒后执行跳转到主视图。 

  • 相关阅读:
    第10组 Beta冲刺(4/5)
    第10组 Beta冲刺(5/5)
    第10组 Beta冲刺(3/5)
    第10组 Beta冲刺(2/5)
    第10组 Beta冲刺(1/5)
    第10组 Alpha事后诸葛亮
    第10组 Alpha冲刺(6/6)
    第10组 Alpha冲刺(5/6)
    软工实践个人总结
    第09组 Beta版本演示
  • 原文地址:https://www.cnblogs.com/freeliver54/p/2241216.html
Copyright © 2011-2022 走看看