Initial impressions of Android Application Development

Source: Internet
Author: User

Some time ago, I finally won the long-awaited HTC G2 Tim and installed various software on my mobile phone. In general, Android applications are relatively less, and there are not many playable games. Among them, jewels is quite playable. In time mode, my current highest score is46230, Compared with the master, I don't know if this score is a little lower. I very much hope that the plants and botnets of PopCap can be transplanted to the Android platform as soon as possible. This game is favored by many players because it is very playable and tests intelligence.

The advantage of a smart phone is that you can install software on your own, or even the software that you write on your mobile phone. AndroidProgramI need to use Java for development, which makes me a little uncomfortable. Because I have never been familiar with Java, although it looks similar to C # in syntax. But there is no way, I decided to stick to eclipse and decide to learn about the development of Android applications, we plan to migrate the nancyglines game previously written in Python to Android in the first project. This is an exciting project for me. The first time I learned how to develop mobile phone software, I hope nancyglines can come out early and put it in the Android Market.

For the sake of my work, we naturally need to first understand the knowledge of Android development. As a result, I found a lot of materials on the Internet. Below is the list of e-books I have found, which can be found on Google. If not, I can leave a message asking me:

Android-a-programmer's-guide

Android-Essentials

Introduction-to-android

Professional_android_2_application_development

Android. application. Development.-. Programming. With. The. Google. SDK. (O 'Reilly,. 2009,. 0596521472)

As I was just getting started, I chose to read the official Android documentation first:

Http://developer.android.com/guide/index.html

The official documentation is very detailed, from the basic introduction, internal architecture, to the entry-level teaching example, to the description of each API. Therefore, I spent two nights working on some basic Android development.ArticleI have read all the examples and made some initial impressions on Android development. Here I will record my learning notes.

To do this, you must first configure the android development environment. I believe many friends, like me, have delayed a lot of time. In fact, the official documents have already been very detailed, so I can only blame that I have not carefully read them. The ADT plug-in is always installed many times. The final reason is that JDK is not installed.

The procedure is as follows:

1. Download and install JDK (5 or 6 ).

2. Download and decompress eclipse.

3. Download the android SDK, decompress it, and set the environment variable path to the tool directory.

4. UseHttps://dl-ssl.google.com/android/eclipse/Download and install Android development tools (ADT) plugin.

5. After installing and restarting eclipse, set the android SDK path in window-preference.

6. Open the android SDK and AVD manager and install the android SDK versions of different platforms, such as andoid2.1 android1.6.

It is not complicated. Next, let's take a look at the android architecture:

As it is a beginner, it is not very appealing to see the figure above. As we go into the future, we should feel more like looking back at this image.

After the development environment is configured, the most effective learning method is to view the official tutorials, including:

    • Hello World
    • Hello views
    • Hello Localization
    • Notepad tutorial

Through the above example, I will understand the following:

1. Activity

Activity controls the objects operated on the user interface. An application can have multiple activities, but only one user interface of the activity can be displayed in front of the user. We need to implement a class that inherits from the activity class. By Rewriting some specific methods of the parent class, we can execute some specificCode. For example, you can press a button to touch a certain point on the screen. For details about the status of the activity, see:

 

2. View

The User Interface layout is described in XML, for example:

<? XML version = "1.0" encoding = "UTF-8" ?>
< Linearlayout Xmlns: Android = "Http://schemas.android.com/apk/res/android"
Android: layout_width = "Wrap_content"
Android: layout_height = "Wrap_content" >
< Listview Android: ID = "@ Android: ID/List"
Android: layout_width = "Wrap_content"
Android: layout_height = "Wrap_content" />
< Textview Android: ID = "@ Android: ID/empty"
Android: layout_width = "Wrap_content"
Android: layout_height = "Wrap_content"
Android: Text = "@ String/no_notes" />

</Linearlayout>

The listview and textview can be considered as some built-in controls. At the same time, we can also implement our own custom view, as long as we inherit the custom View class. For example:

< Com. coderzh. nancyglines. glinesview
Android: ID = "@ + ID/glines"
Android: layout_width = "Fill_parent"
Android: layout_height = "Fill_parent" />

Then implement the glinesview class:

Public ClassGlinesviewExtendsView {

}

One of the most important methods is ondraw, which is used to draw the user content to be presented. For example, I want to write a hello on the screen.

@ Override
Protected   Void Ondraw (canvas ){
// Todo auto-generated method stub
Super . Ondraw (canvas );
Mpaint. settextsize ( 20 );
Mpaint. setcolor (color. Blue );
Canvas. drawtext ( " Hello " , 20 , 20 , Mpaint );
}

3. Intent

Intent indicates what you want to do, And filterintent in androidmanifest. xml indicates what kind of intent your application can process. Sometimes, you can use intent to transmit information between different forms.

4. androidmanifest. xml file

It is equivalent to the Web. config file of ASP. NET and some global configurations. For example, set activity and filterintent.

5. Resource Access R. Java

Accessing resources in Android is very simple. When we add resources to the res directory, the ADT plug-in will automatically update R. java files can easily access resources in any res through the R class. You can also use XML in Chinese on the interface.

6. Database

Using SQLite, there is a ready-made sqlitedatabase class that can be used to operate databases.

The above is just a rough introduction, and more practices are needed for a deeper understanding. However, by understanding the basic content above, we can roughly understand the implementation methods of some steps in the development process. For example, how to set the interface layout, how to trigger an event, how to save data, and how to use resources. In the future, we will summarize the results.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.