WEB开发网
开发学院手机开发Android 开发 Android SDK 开发用户界面 阅读

Android SDK 开发用户界面

 2010-03-23 04:26:00 来源:WEB开发网   
核心提示:Menu),菜单也是用View层次来组织的,Android SDK 开发用户界面(3),但是不要自己定义这个结构,使用onCreateOptionsMenu()和onCreateContextMenu()回调函数并定义菜单的内容,例如你可以定义一个样式,该样式制定了某种字体大小和颜色,Android会自动建立需要的Vi
Menu)。

菜单也是用View层次来组织的,但是不要自己定义这个结构。使用onCreateOptionsMenu()和onCreateContextMenu()回调函数并定义菜单的内容。Android会自动建立需要的View结构并绘制其内容。

菜单也需要处理他们的事件,因此不需要注册事件监听器(event listeners)。当菜单项被选择时,onOptionsItemSelected() 或 onContextItemSelected()方法会被调用。

你也可以在xml中定义菜单的项。

Advanced Topics

Adapters

有时候你希望给view group加入动态元素,这些元素不能硬编码,而是需要和外部数据相绑定。为了实现这一点,你需要用AdapterView作为view group,每一个子view使用adapter来进行初始化。

The AdapterView object is an implementation of ViewGroup that determines its child views based on a given Adapter object. The Adapter acts like a courier between your data source (perhaps an array of external strings) and the AdapterView, which displays it. There are several implementations of the Adapter class, for specific tasks, such as the CursorAdapter for reading database data from a Cursor, or an ArrayAdapter for reading from an arbitrary array.

AdapterView 是ViewGroup的一个实现,该view group使用一个给定的Adapter对象来确定它的子View。Adapter作为数据源(例如一个字符串数组)和AdapterView(负责显示)中的一个联系人。有好几种特殊的Adapter实现,例如CursorAdapter(用于从一个Cursor读取数据库数据)和 ArrayAdapter(用来从任意数组中读取数据)。

Styles and Themes

可以用样式和主题来自定义标准widget的外观。

一个样式是一个或多个格式属性的集合,这些格式属性可以被作为独立的元素放在layout中。例如你可以定义一个样式,该样式制定了某种字体大小和颜色,并将它制定给某几个View元素。

A theme is a set of one or more formatting attributes that you can apply as a unit to all activities in an application, or just a single activity. For example, you could define a theme that sets specific colors for the window frame and the panel background, and sets text sizes and colors for menus. This theme

上一页  1 2 3 4  下一页

Tags:Android SDK 开发

编辑录入:coldstar [复制链接] [打 印]
赞助商链接