安卓工程结构Basic Android project structure

来源:互联网 发布:软件可靠性工程手册 编辑:程序博客网 时间:2024/05/18 00:24

After you have installed all the plug-ins necessary for the development of an Android file, you can now begin to develop an Android application. From the top menu, choose File -> Project, and from the "New Project window", choose "Android Project". Follow the project setup wizard and after finishing the wizard, you will have a basic Android application.Every Android project contains several folders:

  • src: This folder contains the Java source files.
  • gen: Generated Java library, this library is for Android internal use only.
  • Res: Here we can store resource files such as pictures, XML files for defining layouts, and so forth. Within this folder there are additional folders such asDrawable,Layout, andValues.
  • Drawable: Here we store the various graphic files. We can see three types of drawable folders. This is because there are many Android devices with different screen resolutions. By default, there are several versions of this folder such as:Drawable-mdpi,drawable-hdpi, and so forth. This is required in order to adapt to different screen resolutions.
  • Layout: This is the place for XML layout files. Layout files are XML files which define how various Android objects (such as textboxes, buttons, etc.) are organized on the screen.
  • Values: XML files which store various string values (titles, labels, etc.).

Major files in the Android project:

  • AndroidManifest.xml: This is the Android definition file. It contains information about the Android application such as minimum Android version, permission to access Android device capabilities such as internet access permission, ability to use phone permission, etc.
  • MainLayout.xml: This file describes the layout of the page. This means the placement of every component (such as textboxes, labels, radio buttons, user defined components, etc.) on the app screen.
  • Activity class: Every application that occupies the entire device screen needs at least one class which inherits from theActivity class. One major method is calledOnCreate. This method initiates the app and loads the layout page.

gen下面的R.java是在建立项目时自动生成的,这个文件是只读模式,不能更改,R.java文件是定义该项目所有资源的索引文件。

原创粉丝点击