首页 > 代码库 > Android程序中欢迎界面
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 @Override15 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 stub37 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 block44 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程序中欢迎界面
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。