Android Learning Notes (ii) App engineering file analysis _android

Source: Internet
Author: User
Tags static class

Analysis of App engineering files

For information on how to create one of the simplest Android apps please refer to the link:

Android Learning Notes (i) Environmental installation and the first Hello World http://www.jb51.net/article/52593.htm

The completed engineering files are shown in the following illustration, and some of the major documents are analyzed in this paper.


SRC file Analysis

App source files as shown:


Open the source file Mainactivity.java can see the following code:


The main functions of the source code are as follows:

Directory of App source files

Package Com.example.firstapp; 

Classes needed to import the app

Import Android.os.Bundle; 
Import android.app.Activity; 
Import Android.view.Menu; 

Mainactivity inherits from activity

public class Mainactivity extends activity

Overloaded OnCreate method, initializing an activity using a layout file

@Override
protected void onCreate (Bundle savedinstancestate) {
  super.oncreate (savedinstancestate);
  Setcontentview (R.layout.activity_main);
} 

Overloaded Oncreateoptionsmenu method, initializing menu with layout file

@Override Public
Boolean oncreateoptionsmenu (Menu menu) {
  //inflate the menu; This adds items to the Action bar I F it is present.
  Getmenuinflater (). Inflate (R.menu.main, menu);
  return true;
}

Gen and Res files

The Gen folder R.java files are created automatically when the project is created, as read-only files, which define the index of all the resources in the project, and each static class in it corresponds to a resource.

For example:

1. Class drawable associated with a folder containing the drawable typeface in Res

2. Class layout associated with layout folder in Res

3. Class menu is associated with the menu folder in Res

The Res folder is the resource file used by the app, where:

1. drawable and Icon Related

2. Layout and layout-related

3. Menu is related to the menu layout

4. Value defines the values used in the project configuration

Example: text in an interface

The Strings.xml file in the value's folder defines a string named Hello_world, whose value is "Hello world! "
The text in the TEXTVEIW is defined as a Hello_world string in the Activity_main.xml under the Layout folder.
Android Menifest.xml

The main configuration files for the app are as follows:

Configure app Information

Package= "Com.example.firstapp"
android:versioncode= "1"
android:versionname= "1.0"  

Configuring the SDK Level

android:minsdkversion= "8"
android:targetsdkversion= "19"

Configure App Resources

Configure the app's icon, name, and theme, and its resources correspond to the Res folder.

Android:allowbackup= "true"
android:icon= "@drawable/ic_launcher"
android:label= "@string/app_name"


Configure the app's activity and app name

Android:name= "com.example.firstapp.MainActivity"
android:label= "@string/app_name" 

Configure the Intent-filter of the app

Action

  android:name= "Android.intent.action.MAIN"
category

  Android:name= " Android.intent.category.LAUNCHER "

At last

The above for the app engineering file analysis, personal understanding, for reference only.

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.