您的位置:首页 > 移动开发 > Android开发

Android 开发文档 程序基础 ——activity组件

2010-06-19 10:43 519 查看
所谓的activity组件就是用来提供可视化界面的。

一个程序中可以有很多activity组件组成一个粘性的用户界面,但是又彼此独立。每个activity都是Activity基类的子类。

每个activity都有一个默认的window,一般来说,这个window都是充满屏幕,当然也可以小于屏幕并浮动在其他窗口上面。
activity可以使用特定的窗口,比如弹出窗口。

窗口中的可视内容是views(View类衍生的对象)的一个层次。每个views都控制窗口中的一个矩形区域。父级的views包含子级的
views并组织其布局。末端的views相应用户在其区域的操作。也就是说view是activity与用户发生交互的地方。

views是由Activity.setContentView()
方法放置在
activity window中。

转自我的android博客

原文

Activities
An activity
presents a visual
user interface for one focused endeavor the user can undertake. For
example, an activity might present a list of menu items users can
choose from or it might display photographs along with their captions. A
text messaging application might have one activity that shows a list
of contacts to send messages to, a second activity to write the message
to the chosen contact, and other activities to review old messages or
change settings. Though they work together to form a cohesive user
interface, each activity is independent of the others. Each one is
implemented as a subclass of the Activity
base class.

An application might consist of just one activity or, like the text
messaging application just mentioned, it may contain several. What the
activities are, and how many there are depends, of course, on the
application and its design. Typically, one of the activities is marked
as the first one that should be presented to the user when the
application is launched. Moving from one activity to another is
accomplished by having the current activity start the next one.

Each activity is given a default window to draw in. Typically, the
window fills the screen, but it might be smaller than the screen and
float on top of other windows. An activity can also make use of
additional windows — for example, a pop-up dialog that calls for a user
response in the midst of the activity, or a window that presents users
with vital information when they select a particular item on-screen.

The visual content of the window is provided by a hierarchy of views —
objects derived from the base View
class. Each view controls a particular rectangular space within the
window. Parent views contain and organize the layout of their children.
Leaf views (those at the bottom of the hierarchy) draw in the
rectangles they control and respond to user actions directed at that
space. Thus, views are where the activity’s interaction with the user
takes place. For example, a view might display a small image and
initiate an action when the user taps that image. Android has a number
of ready-made views that you can use — including buttons, text fields,
scroll bars, menu items, check boxes, and more.

A view hierarchy is placed within an activity’s window by the Activity.setContentView()

method. The content view
is the View object at the root of the
hierarchy. (See the separate User Interface document for more
information on views and the hierarchy.)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: