androidWord文档下载推荐.docx
《androidWord文档下载推荐.docx》由会员分享,可在线阅读,更多相关《androidWord文档下载推荐.docx(13页珍藏版)》请在冰点文库上搜索。
●通知管理器使得应用程序可以在状态栏中显示自定义的提示信息。
●活动管理器用来管理应用程序生命周期并提供常用的导航回退功能。
系统运行库
●系统C库-一个从BSD继承来的标准C系统函数库Libc),它是专门为基于Embeddedlinux的设备定制的。
●媒体库-基于PacketVideoOpenCORE;
该库支持多种常用的音频、视频格式回放和录制,同时支持静态图像文件。
编码格式包括MPEG4,H.264,MP3,AAC,AMR,JPG,PNG。
●SurfaceManager-对显示子系统的管理,并且为多个应用程序提供了2D和3D图层的无缝融合。
●LibWebCore-一个最新的web浏览器引擎用,支持Android浏览器和一个可嵌入的web视图。
2、环境的搭建:
1、安装JDK:
下载JDK双击进行安装,一路下一步的安装下去。
2、配置JAVA的环境变量:
右击电脑属性,点击里面高级系统设置,点开环境变量:
新建一个系统变量,变量名名称:
JAVA_HOME,值就是JAVA安装的路径:
3、配置CLASS_PATH:
新建一个系统变量,变量名称是CLASS_PATH,值就是
\%JAVA_HOME%\lib\toojarls.jar,%JAVA_HOME%\lib\dt.jar
4、androidSDK的配置:
下载androidSDK开发包android-sdk_r21.1-windows,点开里面的androidSDKmanager
选中一款合适的开发包下载安装,安装好的界面如下所示:
5、添加SDK到环境变量中:
新建一个环境变量Androidpath,变量值就是SDK开发包的位置
6、使用eclipse配置ADT:
●从官网上下载ADT-21.1.0.zip;
●点开eclipse点击HELP->
Installnewsoftware
●Workwith处点击ADD添加ADT-21.1.0.zip;
●选择需要安装的软件,一路点击next进行安装
6.在eclipse中配置androidSDK
●点击eclipse中的window->
preference
●在左边选择android选项,在右边路径处加上SDK的安装路径
●点击apply然后点击ok
3、建立android工程
1、选择File->
New->
Other建立一个android工程
2、点击next,选择SDK然后填写项目名称
3、创建一个android模拟器
●点击图示图标
●点击manageADM,点击New新建一个模拟器
●然后选择这个模拟器点击START
4、新建的androidproject工程一开默认的工程就是helloworld。
我们可以点开helloworld的显示界面,可以看到其初始化的源代码:
<
RelativeLayoutxmlns:
android="
xmlns:
tools="
android:
layout_width="
match_parent"
layout_height="
paddingBottom="
@dimen/activity_vertical_margin"
paddingLeft="
@dimen/activity_horizontal_margin"
paddingRight="
paddingTop="
tools:
context="
.MainActivity"
>
<
TextView
wrap_content"
text="
@string/hello_world"
/>
/RelativeLayout>
从上面我们可以看出,具体的内容和Windowphone开发是类似的。
首先都需要先定义一个layout,设置其相对应的属性;
其次可以根据需要设置文本框;
完成上述操作后,我们可以点击Runasandroidproject在模拟器中运行。
模拟器中的界面如图:
由此可以看出整个系统运行正常。
5、使用android建立一个简单的计算器
1)、计算器逻辑代码:
packagecom.he;
importandroid.app.Activity;
importandroid.os.Bundle;
importandroid.text.InputType;
importandroid.view.View;
importandroid.view.View.OnClickListener;
importandroid.widget.Button;
importandroid.widget.EditText;
importandroid.widget.Toast;
publicclassCalculatorActivityextendsActivity{
//加plus减subtract乘multiply除divide
privateEditTextetResult;
privateButtonbtPlus;
privateButtonbtSub;
privateButtonbtMultiply;
privateButtonbtDivide;
privateButtonbtDelete;
privateButtonbtCe;
privateButtonbtPoint;
privateButtonbtDeng;
privateButtonbt0;
privateButtonbt1;
privateButtonbt2;
privateButtonbt3;
privateButtonbt4;
privateButtonbt5;
privateButtonbt6;
privateButtonbt7;
privateButtonbt8;
privateButtonbt9;
@Override/**Calledwhentheactivityisfirstcreated.*/
publicvoidonCreate(BundlesavedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
etResult=(EditText)findViewById(R.id.etResult);
btPlus=(Button)findViewById(R.id.btPlus);
btSub=(Button)findViewById(R.id.btSubtract);
btMultiply=(Button)findViewById(R.id.btMultiply);
btDivide=(Button)findViewById(R.id.btDivide);
btDelete=(Button)findViewById(R.id.btDelete);
btDeng=(Button)findViewById(R.id.btDeng);
btPoint=(Button)findViewById(R.id.btPoint);
btCe=(Button)findViewById(R.id.btCe);
bt0=(Button)findViewById(R.id.bt0);
bt1=(Button)findViewById(R.id.bt1);
bt2=(Button)findViewById(R.id.bt2);
bt3=(Button)findViewById(R.id.bt3);
bt4=(Button)findViewById(R.id.bt4);
bt5=(Button)findViewById(R.id.bt5);
bt6=(Button)findViewById(R.id.bt6);
bt7=(Button)findViewById(R.id.bt7);
bt8=(Button)findViewById(R.id.bt8);
bt9=(Button)findViewById(R.id.bt9);
etResult.setInputType(InputType.TYPE_NULL);
上面时按键处理的模块,当发现有触摸时候,将制定位置的触碰通过android系统提供的系统调用函数转换为响应的数字,乘除等,将所有的数据转换后,后面就是逻辑上对这些进行数据运算平且显示出来。
后面逻辑考虑到文档内容关系不在罗列。
里面使用的函数分析:
●privateButtonbtPlus;
新建一个按键,这个按键有两个状态一个是check一个是unchecked状态,用于表征是否在这个模块上面有没有触碰产生。
●tPlus=(Button)findViewById(R.id.btPlus);
通过Oncreat(Bundle)来确认指定的id是否有更改。
并且仅确认的值产地给tPlus中。
●btPoint.setOnClickListener(newOnClickListener():
Registeracallbacktobeinvokedwhenthisviewisclicked.Ifthisviewisnotclickable,itbecomesclickable.
4、简单计算器最终使用效果
模拟器中生成的界面
运行9+9以及显示结果:
4、体会和感悟:
通过搭建JAVA环境,建立eclipse的运行环境,这个过程还是有一些复杂,但是经过这些过程后明白了android开发环境是怎么搭建的。
然后通过android的SDK的建立知道了现在android信通更新是非常快,也看到了android作为一款开源软件的一些信息。
最后通过最后自己建立工程在模拟器上运行,了解了android程序整个的开发过程,了一个基本的认识。