Android培训班(49)

接着下来,打开这个文件Calculator.java,查看它的源码,如下:

/*

* Copyright (C) 2008 The Android Open Source Project

*

* Licensed under the Apache License, Version 2.0 (the "License");

* you may not use this file except in compliance with the License.

* You may obtain a copy of the License at

*

* http://www.apache.org/licenses/LICENSE-2.0

*

* Unless required by applicable law or agreed to in writing, software

* distributed under the License is distributed on an "AS IS" BASIS,

* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

* See the License for the specific language governing permissions and

* limitations under the License.

*/

上面这段声明了这个源文件的版权。

 

 

package com.android.calculator2;

这行代码是告诉编译器,这个文件的源码是属于包 com.android.calculator2,以便虚拟机运行时,可以从XML里找到包的代码来运行。

 

 

import android.app.Activity;

import android.os.Bundle;

import android.util.Log;

import android.util.Config;

import android.util.TypedValue;

import android.view.Display;

import android.view.Menu;

import android.view.MenuItem;

import android.view.View;

import android.view.KeyEvent;

import android.widget.Button;

import android.widget.TextView;

这段代码是导入使用的库代码。

 

android.app.Activity类是用户唯一可以看得到的东西,几乎所有的属性都与用户交互相关,所以Activity库主要负责的就是创建显示窗口,就是调用函数setContentView()来显示自己的UI。

 

android.os.Bundle类是用来保存字符串键与其它类型值的映射关系。比如可以通过字符串的键值,就可以找到其类型的值。

 

android.util.Log类是用来输出LOG的API。通常使用 Log.v() Log.d() Log.i() Log.w() Log.e() 等方法来输出LOG内容,这样方便调试/跟踪程序运行。

 

android.util.Config类是获取当前编译的配置方式,比如当前是调试还是发行版本编译。

 

android.util.TypedValue类是用来支持动态的数据类型,主要保存资源里数据。

 

android.view.Display类是显示属性类,用来获取显示相关的属性,比如显示的标识、显示的高度、显示的宽度、刷新频率和旋转等属性。

 

android.view.Menu类是用来管理菜单类,主要有子菜单和弹出式菜单。

 

android.view.MenuItem类是用来管理菜单项。

 

android.view.View类是视图管理类,主要处理界面显示和事件响应。

 

android.view.KeyEvent类是用来管理按键和按钮的事件。

 

android.widget.Button类是按钮管理类。

 

android.widget.TextView类是用来显示和编辑文本。

 

//QQ: 9073204 EMAIL:[email protected]

//蔡军生  2011-05-29

 

下面来看一下Activity类的函数调用流程图,如下:

 

Android培训班(49)

你可能感兴趣的:(android)