zoukankan      html  css  js  c++  java
  • Android商城开发系列(二)——App启动欢迎页面制作

      商城APP一般都会在应用启动时有一个欢迎界面,下面我们来实现一个最简单的欢迎页开发:就是打开商城App,先出现欢迎界面,停留几秒钟,自动进入应用程序的主界面。

      首先先定义WelcomeActivity布局,布局非常简单的,就一张图片,代码如下所示:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:gravity="center">
    
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@mipmap/logo"/>
    
    
    </LinearLayout>

      启动界面时,两秒跳转到另一个界面,代码如下所示:

    package com.nyl.shoppingmall.app.activity;
    
    import android.app.Activity;
    import android.content.Intent;
    import android.os.Handler;
    import android.os.Bundle;
    
    import com.nyl.shoppingmall.R;
    
    /**
     * 欢迎界面
     */
    public class WelcomeActivity extends Activity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_welcome);
            //两秒钟进入MainActivity
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    //启动MainActivity主页面,这段代码是在主线程执行
                    startActivity(new Intent(WelcomeActivity.this,MainActivity.class));
                    //关闭当前页面(结束WelcomeActivity)
                    finish();
                }
            },2000);
        }
    }

      启动页面效果图如下:

      

      两秒钟后跳转到主界面,效果图如下:

      

      这里一个非常简单的启动页面,就学到这里咯!

  • 相关阅读:
    一起学Vue之表单输入绑定
    简单易懂的单元测试框架-gtest(二)
    简单易懂的单元测试框架-gtest(一)
    最常用设计模式-模板方法模式
    最常用设计模式-简单工厂模式
    最常用设计模式-单例模式
    端口复用后门
    内存取证工具-volatility、foremost
    python的exe反编译
    Linux加密known_hosts文件中的IP
  • 原文地址:https://www.cnblogs.com/nylcy/p/6588776.html
Copyright © 2011-2022 走看看