"Xamarin Development Android Series 7" Android Fabric Foundation (bottom)

Source: Internet
Author: User
Tags sqlite database

Earlier we do not intend to carry out too deep things, the province of scare run just entered the door, feel the threshold high, so, we began to be like a marquee, forward leap *************

In the previous article we learned from the Android system, I stressed that our focus is application, including the development of the future we are also developing application, no other.

Our team app has an approximate connection, know. apk composition.

What the real app contains is a conceptual thing, but it has to be known. So we list them and control the relationship.

The first thing we're explaining is its four components Activity/broadcastreceiver/ Service/Content Provider

1.Activity

 an activity is an application component that provides a screen that users can use to interact in order to accomplish a task, such as dialing, taking pictures, sending an email, and looking at a map. Each activity is given a window on which the user interface can be drawn. Windows are usually filled with screens, but can also be smaller than the screen and float on top of other windows. every activity in an Android app must be declared in the Androidmanifest.xml configuration file, or the activity will not be recognized or performed by the system

An application is usually composed of multiple activities, and they are usually loosely coupled. Typically, activity in an application is designated as "main" activity, which is presented to the user when the application is first launched. Each activity can then start another activity in order to complete a different action. Each time an activity starts, the previous activity stops, but the system retains activity on a stack ("Back stack"). When a new activity is started, it is pushed to the top of the stack to get the user focus. The back stack conforms to the simple "last in, first out" principle, so when the user finishes the current activity and then clicks the Go button, it is popped up (and destroyed) before the activity resumes.

2.Service

A service is a long life cycle, without a user-interface program that can be used to develop programs such as monitoring classes. Windows-like services. Can be used for caching processing, large data processing, music media file playback and other background processing.

A good example is a media player that is playing songs from a playlist. In a media player application, there should be multiple activity, allowing the user to select songs and play songs. However, there is no activity associated with the music replay because the user will of course think that the music should still be playing when navigating to other screens. In this example, the Media Player activity uses context.startservice () to start a service so that it can keep the music playing in the background. At the same time, the system will keep the service running until the end of the service run. In addition, we can also connect to a service by using the Context.bindservice () method (if the service is not running it will start it). When connected to a service, we can also communicate with it by the interface provided by the service. Take the Media Player example, we can also pause, replay and other operations.

3.Content Provider

This component provides a data content distribution share, equivalent to its own data of an external interface Provider,android platform provides content provider to make a specified dataset of an application available to other applications. This data can be stored in a file system, in a SQLite database, or in any other reasonable way

4.Broadcast Receivers

The broadcast receiver, as its name implies, is to accept event notifications from the system or program and then forward the Notification Subscriber program. Corresponds to the event subscription broadcast mode in C #. Broadcast receivers Subscribe to the event notification information they need to do their own processing, such as: Battery low, Bluetooth open, and so on, the system pushes the message to the system's event bus, and then the subscriber gets the event, (Event-bus) event bus mode, I'm guessing, I don't know if this is the mode, when WCF is based on azure development, it provides event bus, push notifications to messages from different sources, and send messages to specific subscribers for distribution processing.

5.Views and Viewgroups

The program controls you can see on the program interface are derived from the View class, for example:buttons, labels, textboxes, and radio

Buttons is all examples of views,

View is the base class for all UI components, and ViewGroup is the container that holds these components, which itself is derived from view. The general structure of the Androidui interface can be found in the following:

The creation of a View can be done programmatically or by means of an XML layout. We usually do the development of View controls under the IDE

6.User Interface Widgets

Interface components, Android provides a friendly interface experience development based on the component form, the parts set under the framework of the Android.widget

7. Common layouts Layout (five layout modes)

1 LinearLayout Linear layout

Linear layout, this thing, from the outer frame can be understood as a Div, he first is a one from the top down listed on the screen. Each of the linearlayout can be divided into vertical layouts (android:orientation= "vertical") and horizontal layouts (android:orientation= "horizontal"). When vertical layout, there is only one element for each row, and multiple elements are descending vertically; when horizontal layout, there is only a row, and each element is arranged to the right.
There is an important attribute android:layout_weight= "1" in the LinearLayout, which represents the line spacing when vertical layout, the column width when horizontal, the larger the weight value.

The preview in the linear layout is exactly the same as in the real machine.

TextView occupies a certain space, there is no assignment or a certain width, pay special attention.

2 Framelayout

Framelayout is one of the simplest layout objects. It is customized as a blank alternate area on your screen, after which you can populate a single object-for example, a picture you want to publish. All child elements will be pinned to the upper-left corner of the screen; You cannot specify a location for a child element in Framelayout. The latter child element will overwrite the padding directly above the previous child element, blocking them partially or completely (unless the latter element is transparent).
3, Absolutelayout
Absolutelayout This layout is simple, the main properties of the two layout_x and layout_y respectively define the absolute position of this component. That is, the X, y value of the axis (0,0) in the upper-left corner of the screen, when moving down or to the right, the coordinate value becomes larger. Absolutelayout does not have a page border, allowing elements to overlap each other (although not recommended). We don't usually recommend using absolutelayout unless you have a legitimate reason to use it because it makes the interface code too rigid that it might not work well on different devices.

4, Relativelayout
The relative layout can be understood as the layout of an element as a reference object.

5, Tablelayout

The table layout is similar to the table in HTML. Each of the tablelayout has a table row Tablerow,tablerow inside can define each element in detail. Each TableRow defines a row (in fact, you can define other sub-objects, which are explained below). The Tablelayout container does not display the row, cloumns, or cell border lines. Each row has 0 or more cells, and each cell has a view object. A table consists of columns and rows that make up many cells. Table allows cells to be empty. Cells cannot span columns, which is not the same as in HTML.

  Tabrow only on rows, regardless of column (column custom).

(Layout reference from: http://www.cnblogs.com/chiao/archive/2011/08/24/2152435.html)

8.Adapter layouts Self-adapting layout

List View

Grid View

Two self-adapting layouts

9.XML Layout Files

A page layout file, an XML file that contains Tags for the declaration of the layout control, each corresponding to the corresponding control class, and the property for the initialization of the control assignment. Each control has a unique ID,

such as: android:id= "@+id/searchbutton", @ tells the parser that this is the id,+ representation of the control to register to the resource file to R.java, in the resource file, the corresponding integer numeric ID is identified to the control.

10.Intents

The message bearer container, which is used to communicate between the various parts of Android, is hosted by the message.

Mainly used for: 1, form activity data transfer 2, service data notification 3, communication data transfer between components

One. Resources

Implementation of the program's resource files, images, audio, video, files, animation menus, style operation management.

. r.java file

When the project is compiled, the resource file ID in the package is placed in the R.java file of the program, and the R class file contains the identity ID of the int type of each resource. Such as:

After reading the above content, our knowledge of the development of the app is basically complete. Again: There is no deep level of explanation. After proficiency, the concept of each component can be further studied.

"Xamarin Development Android Series 7" Android Fabric Foundation (bottom)

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.