zoukankan      html  css  js  c++  java
  • 手机安全卫士开发系列(2)——splash界面

    一、Android中的MVC

    (1)activity主要用来页面的展示

    (2)engine包:获取数据和展示数据(包含数据适配器)

    (3)domain包:存放数据实体

    第一种包结构组织关系:


    第二种包结构:

     利用程序的业务逻辑进行代码划分,比如QQ, qq有登陆模块,聊天模块,群组模块,qq空间模块

    com.tencent.login

    com.tencent.im

    com.tencent.group

    com.tencent.zoom

    二、建立工程和包

    splash主要用于闪屏的显示(包括产品logo显示,数据库初始化,获取服务器最新信息是否有新版本更新,)

    市场上不少应用会在不同时间显示不同logo,这是怎么做的呢?是事先偷偷的将logo就下载好了,到了特定的某一天就会加载到该界面。

    我建立的工程如下:


    要注意在mainfest文件里面的路径配置:package=" "  android:name=" "

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.example.mobiesafe"
        android:versionCode="1"
        android:versionName="1.0" >
    
        <uses-sdk
            android:minSdkVersion="8"
            android:targetSdkVersion="17" />
    
        <application
            android:allowBackup="true"
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
            android:theme="@style/AppTheme" >
            <activity
                android:name=".ui.SplashActivity"
                android:label="@string/app_name" >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
    
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
        </application>
    
    </manifest>
    


    现在创建布局文件splash.xml

    <?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:background="@drawable/logo2"
        android:gravity="center_horizontal"
        android:orientation="vertical" 
        android:id="@+id/ll_splash_main"
        >
    	<!-- 显示版本号 -->
        <TextView
            android:id="@+id/tv_splash_version"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="280dip"
            android:text="版本号"
            android:textColor="#FF01b6f8"
            android:textSize="20sp" />
    	<!-- 下载进度条 -->
        <ProgressBar
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="50dip" />
    
    </LinearLayout>


    SplashActivity

    package com.meritit.mobiesafe.ui;
    
    import android.app.Activity;
    import android.app.ProgressDialog;
    import android.content.pm.PackageInfo;
    import android.content.pm.PackageManager;
    import android.os.Bundle;
    import android.view.Window;
    import android.view.WindowManager;
    import android.view.animation.AlphaAnimation;
    import android.widget.LinearLayout;
    import android.widget.TextView;
    
    import com.example.mobiesafe.R;
    
    public class SplashActivity extends Activity {
    	private static final String TAG = "SplashActivity";
    	private TextView tv_splash_version;
    	private LinearLayout ll_splash_main;
    	private ProgressDialog pd ;
    	private String versiontext;
    
    	@Override
    	public void onCreate(Bundle savedInstanceState) {
    		super.onCreate(savedInstanceState);
    		// 取消标题栏
    		requestWindowFeature(Window.FEATURE_NO_TITLE);
    		setContentView(R.layout.splash);
    		ll_splash_main = (LinearLayout) this.findViewById(R.id.ll_splash_main);
    		tv_splash_version = (TextView) this
    				.findViewById(R.id.tv_splash_version);
    		versiontext = getVersion();
    		tv_splash_version.setText(versiontext);
    		AlphaAnimation aa = new AlphaAnimation(0.0f, 1.0f);
    		aa.setDuration(2000);
    		ll_splash_main.startAnimation(aa);
    
    		// 完成窗体的全屏显示 // 取消掉状态栏
    		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
    				WindowManager.LayoutParams.FLAG_FULLSCREEN);
    
    	}
    
    	/**
    	 * 获取当前应用程序的版本号
    	 * 
    	 * @return
    	 */
    	private String getVersion() {
    		try {
    			//包管理服务
    			PackageManager manager = getPackageManager();
    			//第一个参数为包名
    			PackageInfo info = manager.getPackageInfo(getPackageName(), 0);
    			return info.versionName;
    		} catch (Exception e) {
    
    			e.printStackTrace();
    			return "版本号未知";
    		}
    	}
    	
    }
    


    运行结果



    源代码下载:http://download.csdn.net/detail/lxq_xsyu/5928701



  • 相关阅读:
    Serialization and deserialization are bottlenecks in parallel and distributed computing, especially in machine learning applications with large objects and large quantities of data.
    Introduction to the Standard Directory Layout
    import 原理 及 导入 自定义、第三方 包
    403 'Forbidden'
    https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
    These interactions can be expressed as complicated, large scale graphs. Mining data requires a distributed data processing engine
    mysqldump --flush-logs
    mysql dump 参数
    mysql dump 参数
    如果是在有master上开启了该参数,记得在slave端也要开启这个参数(salve需要stop后再重新start),否则在master上创建函数会导致replaction中断。
  • 原文地址:https://www.cnblogs.com/pangblog/p/3257982.html
Copyright © 2011-2022 走看看