zoukankan      html  css  js  c++  java
  • Android程序中欢迎界面

    额,在做项目中,肯定首先要用到欢迎界面,下面是我在做项目中用的最简单的一个欢迎界面,即打开程序时,先是显示一张图片,然后等一段时间后图片消失,进入登录界面。直接上代码,有注释也不用解释了:

     首先是Welcom.java

     1 import cn.nedu.math.ninebox.R;
     2 import android.app.Activity;
     3 import android.content.Intent;
     4 import android.content.res.Configuration;
     5 import android.os.Bundle;
     6 import android.os.Handler;
     7 import android.os.Message;
     8 import android.view.Window;
     9 import android.view.WindowManager;
    10 
    11 public class Welcome extends Activity {
    12     private Handler handler;
    13 
    14     @Override
    15     public void onCreate(Bundle savedInstanceState) {
    16         super.onCreate(savedInstanceState);
    17          //设置全屏
    18         this.requestWindowFeature(Window.FEATURE_NO_TITLE);  //去掉标题栏(应用程序的名字)
    19         getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,  //隐去状态栏部分(电池等图标和一切修饰部分)
    20                 WindowManager.LayoutParams.FLAG_FULLSCREEN);
    21         
    22     //启动一个线程加载欢迎界面
    23         setContentView(R.layout.welcome);
    24         handler = new Handler() {
    25             public void handleMessage(Message msg) {
    26                 if (msg.arg1 == 1) {
    27                     Intent intent = new Intent();
    28                     intent.setClass(Welcome.this, DengLu.class);
    29                     startActivity(intent);
    30                     finish();
    31                 }
    32             }
    33         };
    34         new Thread() {
    35             public void run() {
    36                 // TODO Auto-generated method stub
    37                 try {
    38                     sleep(1500);     //线程暂停1.5秒,单位毫秒
    39                     Message msg = handler.obtainMessage();
    40                     msg.arg1 = 1;
    41                     handler.sendMessage(msg);  //发送消息
    42                 } catch (InterruptedException e) {
    43                     // TODO Auto-generated catch block
    44                     e.printStackTrace();
    45                 }
    46             }
    47         }.start();   //在需要的地方启动线程
    48     } 
    49                 //当屏幕显示(横屏竖屏发生切换时)调用的方法
    50     public void onConfigurationChanged(Configuration newConfig) {
    51 
    52         super.onConfigurationChanged(newConfig);
    53     }
    54 }

    welcom.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="@drawable/huanyingtupian"
        android:orientation="vertical" >
    
    </LinearLayout>
    
    我是刚刚进入公司的Android实习生,菜鸟一枚,博客记录我犯过的错,收获的东西,学到的知识和技术,可能里面会有很多错误的地方,幼稚的地方,欢迎大家指出来,帮助我进步,但请别伤害我,我只是菜鸟一枚,我在努力争取进步。
  • 相关阅读:
    3.4.2内核下的I2C驱动
    AS3批量替换文件
    文件访问权限
    Windows快捷键
    整数与字符串之间的转换函数
    Windows获取文件大小
    Windows内核对象
    ASCII字符集
    IP协议
    获取真正的进程/线程句柄
  • 原文地址:https://www.cnblogs.com/smilefortoday/p/3996077.html
Copyright © 2011-2022 走看看