android歡迎介面的編程實現[手相評分-軟體執行個體]

來源:互聯網
上載者:User


首先,我們可以先看一下“手相評分”這款軟體的啟動畫面。如下:

其實,做歡迎介面的原理非常簡單,就是在onCreate函數中啟動一個線程,線程體在睡眠幾秒鐘之後,跳轉
到MainActivity即可。具體實現代碼如下:
WelcomeActivity.java

import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.os.Handler;import android.os.Message;import android.view.Window;import android.view.WindowManager;/* *@author: ZhengHaibo   *web:     http://blog.csdn.net/nuptboyzhb *mail:    zhb931706659@126.com *2013-3-25  Nanjing,njupt,China */public class WelcomeActivity extends Activity {private static final int GOTO_MAIN_ACTIVITY = 0;@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);// 設定無標題requestWindowFeature(Window.FEATURE_NO_TITLE);// 設定全屏getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);setContentView(R.layout.activity_welcome);MyTimer timer = new MyTimer();timer.start();//啟動線程}Handler mHandler = new Handler() {public void handleMessage(Message msg) {switch (msg.what) {case GOTO_MAIN_ACTIVITY:Intent intent = new Intent();intent.setClass(WelcomeActivity.this, SystemMain.class);startActivity(intent);finish();break;default:break;}};};public class MyTimer extends Thread {public MyTimer() {// TODO Auto-generated constructor stub}@Overridepublic void run() {// TODO Auto-generated method stubtry {Thread.sleep(3000);// 線程暫停時間,單位毫秒mHandler.sendEmptyMessage(GOTO_MAIN_ACTIVITY);} catch (InterruptedException e) {// TODO Auto-generated catch blocke.printStackTrace();}}}}

布局代碼activity_welcome.xml

<?xml version="1.0" encoding="utf-8"?><LinearLayoutandroid:layout_width="fill_parent"android:layout_height="fill_parent"android:orientation="horizontal"android:background="@drawable/welcome"xmlns:android="http://schemas.android.com/apk/res/android"></LinearLayout>

對了,廣告一下,手相評分即是本人開發,多謝大家支援!以後會寫該軟體影像處理方面的實現方法,敬請期待!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.