Program Ape Learn English on the visual English web
Android Program Development 0 Basic Tutorial (i)
Platform Brief Introduction 's exciting Google mobile OS platform-android officially announced on November 13, 2007, an open-source operating system with Linux as its kernel. As a developer, we are concerned with the architecture of this platform and the supported development languages. Here is the platform architecture model: This platform has the following features: + application framework: Reusable and replaceable component parts, where all the software is equal. + Dalvik Virtul machine: A Linux-based VM. + Integrated Browser: A browser based on an open source WebKit engine, at the application layer. + Optimized Graphics: includes a self-defined 2D graphics library and 3D implementations based on the OpenGL ES 1.0 standard. + SQLite: Database + Media Support: Universal audio, video and supports for various image formats (MPEG4, H. MP3, AAC, AMR, JPG, PNG, GIF) + GSM telephony:gsm mobile network, hardware Support. + Bluetooth, EDGE, 3G, and WiFi: all dependent on hardware support. + Camera, GPS, compass, and accelerometer: all rely on hardware support. + Rich Development environment: includes a complete set of development tools for easy tracking debugging, memory detection and performance testing, and a plugin for eclipse. Below we will come to experience the development of Android programs. First introduce the development environment, the following is the system and related software version number requirements: operating system: windows XP or Vista Mac OS X 10.4.8 or later (x86 only) Linux (tested O n Linux Ubuntu Dapper Drake) supported development environments eclipse Eclipse 3.2, 3.3 (Europa) Android development Tools plugin (optional) Other development environments or IDEs JDK 5 oR JDK 6 (JRE alone is not sufficient) isn't compatible with Gnu Compiler for Java (GCJ) Apache Ant 1.6.5 or later for Linux and MAC, 1.7 or later for Windows I use Eclipse 3.3 + JDK 1.6. + Ant 1.7 combination. There are two more important: the Android SDK and Android for plugins in Eclipse. android download links for the SDK: Http://code.google.com/android/ Assuming you are using these software for the first time, be aware of the installation sequence and setting environment variables. The general order is to first install the JDK and then unzip the ant Tarball, then set the Java environment variables and the ant environment variables, then unzip the Android SDK and set the environment variables for the Android SDK. In short, add the path of the JDK, ANT, and Android SDK to path. android for Eclipse plug in the installation process is very easy, through the network installation plug-in can be, this is url:https://dl-ssl.google.com/android/eclipse/ Detailed configuration process, able to view:http://code.google.com/android/intro/installing.html#otherides below for a translation of Google to give a hello Android Development Steps:
Create a project: Creating a new project is very easy, just install the Eclipse plugin, and your Eclipse software version number is 3.2 or 3.3, and you can start developing it. First, take a look at the steps to create a "Hello, World" program from the Advanced Level: 1, create a new project "Android Project" 2, and fill in the various parameters of the new project through the Project menu, File----. 3. Edit the code template that you have actively generated. To do this, we complete each step with the following specific instructions. 1. Create a new Android project to launch Eclipse, choose the File---New Project menu, if you have installed your Android Eclipse plugin, you will see "Android Project" in the dialog box that pops up 's Options. Select "Android Project" and click Next button. 2. Fill in the details of the project. The following dialog box requires you to enter the parameters related to the project: This table specifically describes the meaning of each of the parameters: Project name: The names of the directories that include this project. Package name, which follows the Java specification, is very important to distinguish different classes with the package name, and the example uses "Com.google.android", and you should use the name of a path that differs from this one in accordance with your plan. Activity name: This is the main class name of the project, and this class will be the subclass of the activity class of Android. An activity class is a simple launcher and control program class. It can be created based on the need to create an interface, but not necessary. Application Name: An easy-to-read title on your application. In the "Use default location" option in the "Selection bar", you agree to select an existing project. 3. Edit the code that you actively generate. When the project is created, the helloandroid you just created will include the following code. Public class Helloandroid extends activity{/** Called when the activity is first created. * /@OverridePublic void OnCreate (Bundle icicle) {super.oncreate (icicle);Setcontentview (r.layout.main); }} below we start to change it [build interface] When a project is established, the most direct effect is to display some text on the screen, the following is the finished code, we will explain in line. public class Helloandroid extends Activity {/** Called when the activity is first created. * /@OverridePublic void OnCreate (Bundle icicle) {super.oncreate (icicle);TextView TV = new TextView (this);Tv.settext ("Hello, Android");Setcontentview (TV); }} Note You also need to add import android.widget.TextView; At the beginning of the code. In Android programs, the user interface is organized by a class called views. A view can be simply understood as an object that can be drawn, such as selecting a button, an animation, or a text label (in this program), the view subclass of which the text label is displayed is called TextView. How to construct a textview: texiview TV = new TextView (this), textview is a context instance of the Android program, Context controls system invocation, which provides such things as resource parsing, access to databases, and so on. The activity class inherits from the context class, because our helloandroid is a subclass of activity, so it is also a context class, so we can use "this" in the TextView construct. When we've finished building TextView, we need to tell it what it shows: tv.settext ("Hello, Android"); This step is very easy, and when we're done with these steps, Finally, the TextView will be displayed on the screen. setcontentview (TV); activity's Setcontentview () method indicates which view the system uses as an activity interface, assuming that an activity class is not running this method, There will be no interface and display white screen. In this program, we want to display the text, so we pass in the created TextView. Good, the program code has been written, the following to see the effect of execution. Execute code: Hello, android using the Android Eclipse plugin makes it very easy to execute your program and choose Run-and Open run Dialog. You will see the following dialog next, highlight the "Android Application" tab, then press the icon in the top left corner (just like a piece of paper tape), or simply double-click on the "Android Application" tab, You will see a new execution project called "New_configuration" . take a name that can be ideographic, for example "Hello, Android", and then BRowserbutton Select your project (assuming you have very many projects in eclipse, make sure you select the project to be executed), then the plugin will proactively search the activity class in your project and add all the found to the drop-down list of the Activity tab. We only have a "Hello, Android" item, so it will be selected as the default. Click "Apply" button, here, is finished, you just need to click "Run" button, then the Android emulator will be launched, your application will be displayed. Next time, we'll show you how to put the layout of the interface in XML and use the command line to compile and execute the Android program.
Android Program Development 0 Basic Tutorial (i)