11
App的结构
解析Android程序 There are four building blocks to an Android application: Activity Intent Receiver Service Content Provider 在Android应用程序中有四个构建块: 活动 活动内容接受器(意图接收器?) 服务 内容提供器 Not every application needs to have all four, but your application will be written with some combination of these. Once you have decided what components you need for your application, you should list them [...]
11
Hello world
Hello, Android! First impressions matter, and as a developer you know that the first impression you get of a development framework is how easy it is to write “Hello, World!” Well, in Android, it’s pretty easy. Here’s how it looks: 第一印象,作为一个开发人员,我们对一个新的开发框架的第一印象通常是看他的”Hello,World!”程序有多简单。在Android中,实现起来是非常简单的。 实现Hello World需要几个步骤: Create the Project Construct the UI Run the Code: Hello, Android 创建项目 [...]
11
安装SDK
下载SDK 本页介绍了如何安装Android的SDK开发包和配置开发环境。如果你还没有下载SDK,点击下面的链接开始 Download the SDK 系统和软件配置要求 要通过Android SDK中提供的代码和工具进行Android应用程序的开发,需要一个合适的用于开发的电脑和合适的开发环境,具体要求如下: 支持的操作系统 Windows XP 或者 Vista Mac OS X 10.4.8 或更新的版本(只支持x86架构) Linux(在Ubuntu Dapper Drake上测试过) 支持的开发环境 Eclipse Eclipse 3.2,3.3(Europa) Android开发工具插件(可选) 其他的开发环境或者IDE JDK5.0或者JDK6.0(仅有JRE是不够的) 与GNU的Java编译器不兼容 Apache Ant对Linux和Mac版本需要1.6.5或更新,对Windows版本需要1.7或更新
10
额外
额外的练习(Extra Credit) In this exercise, you will use the debugger to look at the work you did in Exercise 3. This exercise demonstrates: How to set breakpoints to observe execution How to run your application in debug mode [Exercise 1] [Exercise 2] [Exercise 3] [Extra Credit] 在本练习中,你将使用调试器观察在记事本练习3中所完成的程序。 本练习示范了如下内容: 如何设置断点来观察程序执行过程 如何在调试模式下运行你的程序 [Exercise 1] [Exercise 2] [Exercise [...]
10
记事本2
记事本练习 2 在这一练习中,你将添加第二个活动到你的notepad应用中,从而允许用户创建、编辑和删除便签。新的活动将用户的输入打包到一个由相应的intent提供的Bundle的方式来创建新的便签。这一节将演示: 创建一个新的活动并且将它添加到Android的manifest 文件中 通过使用startSubActivity() 方法来异步调用另一个活动. 通过Bundle在活动之间传递数据 如何使用更多的屏幕布局高级特性
10
记事本1
记事本练习 1 In this exercise, you will construct a simple notes list that lets the user add new notes but not edit them. The exercise demonstrates: 在这个练习中,你将要创建一个简单的记事本列表,用户可以添加新的记事但是不能编辑他们。这个练习示范了如下内容: The basics of ListActivities and creating and handling menu options. How to access/store the notes in an SQLite database to store the notes. How to bind data into [...]
10
入门指引:记事本应用
入门指引:记事本应用 The tutorial in this section gives you a “hands-on” introduction to the Android framework and the tools you use to build applications on it. Starting from a preconfigured project file, it guides you through the process of developing a simple notepad application and provides concrete examples of how to set up the project, develop [...]
9
Content Provider
应用程序能够将它们的数据保存到文件中、SQL数据库中,甚至是任何有效的设备中。当你想将你的应用数据与其它的应用共享时,Content Provider将会很有用。一个Content Provider类实现了一组标准的方法,从而能够让其它的应用保存或读取此Content Provider处理的各种数据类型。 Applications can store their data in files, an SQLite database, or any other mechanism that makes sense. A content provider, however, is useful if you want your application’s data to be shared with other applications. A content provider is a class that implements a standard set of methods to let other [...]
9
Service
一个Service是一段长生命周期的,没有用户界面的程序。比较好的一个例子就是一个正在从播放列表中播放歌曲的媒体播放器。在一个媒体播放器的应用中,应该会有多个activity,让使用者可以选择歌曲并播放歌曲。然而,音乐重放这个功能并没有对应的activity,因为使用者当然会认为在导航到其它屏幕时音乐应该还在播放的。在这个例子中,媒体播放器这个activity会使用Context.startService()来启动一个service,从而可以在后台保持音乐的播放。同时,系统也将保持这个service一直执行,直到这个service运行结束。另外,我们还可以通过使用Context.bindService()方法,连接到一个service上(如果这个service还没有运行将启动它)。当连接到一个service之后,我们还可以service提供的接口与它进行通讯。拿媒体播放器这个例子来说,我们还可以进行暂停、重播等操作。 A Service is code that is long-lived and runs without a UI. A good example of this is a media player playing songs from a play list. In a media player application, there would probably be one or more activities that allow the user to choose songs and start playing them. However, the music [...]

