手机安全卫士开发系列(2)——splash界面
来源:互联网 发布:硕鼠软件下载 编辑:程序博客网 时间:2024/06/05 02:03
一、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;@Overridepublic 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
- 手机安全卫士开发系列(2)——splash界面
- 手机安全卫士开发系列(6)——程序主界面
- 手机安全卫士1——splash
- 手机安全卫士开发系列(1)——功能列表
- 手机安全卫士开发系列(5)——自动更新
- 手机安全卫士开发系列(7)——知识点整理(2)
- android应用程序安全卫士——1、splash界面实现方法
- 手机安全卫士------Splash页面
- 安卓开发小练手之手机卫士开发(1)——Splash界面
- 手机安全卫士开发系列(7)——知识点整理(1)
- 手机安全卫士开发系列(3)——获取更新的服务器配置
- 手机安全卫士开发系列(4)——显示更新对话框
- Android应用开发系列(一):splash引导界面开发
- 【边做项目边学Android】手机安全卫士02:splash界面ui
- Android项目:手机安全卫士(1)—— 闪屏界面
- Android项目:手机安全卫士(3)—— 主界面布局
- 手机卫士2---splash界面的作用
- Android项目:手机安全卫士(2)—— 版本升级
- HDU 3395 Special Fish
- HDU1102 Constructing Roads 最小生成树
- 2013年8月13日报
- 一个应届计算机毕业生的2012求职之路
- 读《为什么我们的学校总是培养不出人才》有感
- 手机安全卫士开发系列(2)——splash界面
- ===============【转载区】=================
- LeetCode-Symmetric Tree
- 几种任务调度的 Java 实现方法与比较
- 状态压缩dp hdu 4539 郑厂长系列故事——排兵布阵
- float布局和inline-block布局【原创】
- 数据库工具java部分
- spring 自定义schema
- svn