android sdk解析,3.3 解析Android SDK实例(1)

3.3  解析Android SDK实例(1)

在Android的目录中有一个名为"samples"的文件夹,下面存放了SDK中的几个演示实例。这些实例从不同的方面展示了SDK的特性。例如"android-3"中的实例文件夹如图3-8所示。

8043075d4572e15de4dedf936cff6fc9.png

(点击查看大图)图3-8  演示实例结构

1.HelloActivity

这和其他编程语言中的Hello World程序类似,是一个Android平台上的最简单程序,运行后将在手机上显示出"Hello World"的提示。打开Eclipse,将"HelloActivity"导入,然后查看执行后的效果,具体如图3-9所示。

注意:在查看安装目录中的"samples"实例时,不能使用"Import"将实例导入到Eclipse中。要查看实例的运行效果,需要按照下面的步骤操作。

1)Eclipse中依次单击"file"→"new"→"android project",弹出"new android project"对话框。在里面选择"create project from existing source"选项,然后单击"Browse"按钮,并选择对应的实例文件夹即可,如图3-10所示。

3460db6005df1d1e1a1f68bf3aed53fe.png

图3-9  执行效果(1)

4373909599c583b1f850ee610c551390.png

图3-10 "New Android Project"对话框

2)单击"Finish"按钮完成操作,这样即可将实例程序成功导入到Eclipse中。

2.视图组件SkeletonApp

本实例展示了如何在Android中应用提供的视图组件,如常见的EditText、Button、ImageView和菜单等,还演示了如何操作这些组件。执行后的效果如图3-11所示。

3.API应用实例ApiDemos

ApiDemos演示了很多API的使用方法,包括app、content、graphic、media等,如图3-12所示。

4c3caaa36059ba7e6333a869d7606e07.png

图3-11  执行效果(2)

7e32f59240c43b3143b9855b4b0f96c8.png

图3-12  执行效果(3)

【责任编辑:book TEL:(010)68476606】

点赞 0

List of Sample Apps The list below provides a summary of the sample applications that are available with the Android SDK. Using the links on this page, you can view the source files of the sample applications in your browser. You can also download the source of these samples into your SDK, then modify and reuse it as you need. For more information, see Getting the Samples. API Demos A variety of small applications that demonstrate an extensive collection of framework topics. Backup and Restore A simple example that illustrates a few different ways for an application to implement support for the Android data backup and restore mechanism. Bluetooth Chat An application for two-way text messaging over Bluetooth. BusinessCard An application that demonstrates how to launch the built-in contact picker from within an activity. This sample also uses reflection to ensure that the correct version of the contacts API is used, depending on which API level the application is running under. Contact Manager An application that demonstrates how to query the system contacts provider using the ContactsContract API, as well as insert contacts into a specific account. Home A home screen replacement application. JetBoy A game that demonstrates the SONiVOX JET interactive music technology, with JetPlayer. Live Wallpaper An application that demonstrates how to create a live wallpaper and bundle it in an application that users can install on their devices. Lunar Lander A classic Lunar Lander game. Multiple Resolutions A sample application that shows how to use resource directory qualifiers to provide different resources for different screen configurations. Note Pad An application for saving notes. Similar (but not identical) to the Notepad tutorial. SampleSyncAdapter Demonstrates how an application can communicate with a cloud-based service and synchronize its data with data stored locally in a content provider. The sample uses two related parts of the Android framework — the account manager and the synchronization manager (through a sync adapter). Searchable Dictionary A sample application that demonstrates Android's search framework, including how to provide search suggestions for Quick Search Box. Snake An implementation of the classic game "Snake." Soft Keyboard An example of writing an input method for a software keyboard. Spinner A simple application that serves as an application-under-test for the SpinnerTest sample application. SpinnerTest An example test application that contains test cases run against the Spinner sample application. To learn more about the application and how to run it, please read the Activity Testing tutorial. TicTacToeLib An example of an Android library project that provides a game-play Activity to any dependent application project. For an example of how an application can use the code and resources in an Android library project, see the TicTacToeMain sample application. TicTacToeMain An example of an Android application that makes use of code and resources provided in an Android library project. Specifically, this application uses code and resources provided in the TicTacToeLib library project. Wiktionary An example of creating interactive widgets for display on the Android home screen. Wiktionary (Simplified) A simple Android home screen widgets example.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值