Android Learning Note No.5

Source: Internet
Author: User

Intent can be understood as messengers
By intent to assist in the completion of communication between the various components of Android.
Feel the foundation is weak and then review the basic knowledge, sorted out again!
Gen Save auto-generated R resource folder
Gen->com.android.helloworld.activity Package Name
R.java Project Auto-generated resource index class
Android 2.3.3->android.jar Android SDK jar file
Assets the folder where the original resource is saved
Res Resource Folder
Drawable saving pictures and other resource folders
Drawable-icon.png icon File
Layout interface Layouts File
Layout->main.xml Interface Layout File
Values simple Value Configuration folder
Values->strings.xml String configuration file
Androidmainfest.xml Android Configuration manifest file
Default.xml Properties File

PT: Is the physical size of the screen with a size of 1 inches of 1/72.
Android:textscalex Sets the spacing between text, the default is 1.0f
Android:textcolorlink the color of the text connection
Android:textcolorhint sets the color of the message text, The default is gray. Used in conjunction with hint.
Android:textcolorhighlight: The background color of the selected text, which is blue by default.
Android:textappearance: Sets the appearance of text. Eg:?android:attr/textappearancelargeinverse here refers to the system comes with an appearance,? Indicates whether the system has this appearance, otherwise the default appearance is used.
ANDROID:SHADOWDX: Sets the starting position of the shadow horizontal axis.
Android:shadowdy: Sets the starting position of the shadow ordinate. The
Android:shadowradius sets the radius of the shadow. Set to 0.1 to become the color of the font, generally set to 3.0 effect is better.
Android:shadowcolor: Specifies the color of the text shadow that needs to be used with Shadowradius.
Android:phonenumber: Sets the input method for the phone number. The
Android:password is displayed as a decimal point in the form of a password. The
Android:ems sets the width of the TextView to n characters. Override the EMS option when used in conjunction with Minems and Maxems.
Android:marqueerepeatlimit When the Ellipsize property is marquee, sets the number of times the marquee repeats scrolling, which is repeated when set to Marquee_forever. The
Android:buffertype specifies the text category that is obtained by the GetText () method.
An Android application consists of four parts:
1.activity
2.Intent Receiver
3.Service
4.Content Provider

1. An activity is usually a separate screen in the application. Each activity is implemented as a separate class that inherits from the activity base class. Class will display a user interface consisting of view and response events. Most applications consist of multiple screens. For example, a text message sender might have a screen that displays a list of contacts to send messages, a screen to edit a text message to the selected contact, and a different screen to display the previous information or change the settings. Each of these screens should be implemented as an activity. Moving to another screen is done by starting a new activity. For some reason, an activity may return a value to a previous activity-for example, an activity that lets the user select a photo will return the selected photo to the caller application. When a new screen is turned on, the previous screen is paused and pressed into the history stack. The user can navigate back to the screen that was previously opened in the history. The screen can also be selected to be removed from the history stack when they are left inappropriately. Android keeps the history stack for every application running from the home screen.
2.Intent and Intent Filter
Android uses a special class called intent to move applications from one screen to another. Intent describes the intent of an application. Two important parts of the intent data structure are: the corresponding action and data. The typical action value is main (the entry for the application), View,pick,edit, and so on. Data is represented as a Uniform Resource delimiter (URI), for example: To see a Web site in a browser, you will create a intent with the even view action and data with the site URI set.

Android application basic function unit activity a Android.app.Activity class object (object).

Resources compiled by their own applications can be used without the package suite name directly
R.resource_type.resource_name can be quoted. Android contains a number of standard resources, such as screen style and button backgrounds. In order to refer these resources to your code, you must use Android to express them. Android. R.drawable.button_background

Ui–java Way skipped ~ ~ ~

Debugging in Android is not possible with System.out.println (...) To do,
Android offers a number of powerful debugging features-logcat

LogCat is part of the DDMS (Dalvik Debug Monitor Service). It provides a mechanism for collecting and viewing the debug output of the system. Log and system parts from unused applications are collected in Logcat that can be viewed and filtered.

V More information
D Commissioning
I Information
W Warning
E Error

Activity jumps can be done through intent. Below is the activity jump code, here Red has two activity, one is activity A, the other is activity B, the code is as follows:
Intent in = new Intent (a.this,b.class);
StartActivity (in);
By executing these two lines of code, you can jump from activity A to
Activity B.

A class that is related to Intent is called Intent Filters if Intent is a valid request, Intent Filters is used to describe which Intent an activity (or Intent Receiver) can manipulate. An activity if you want to show a person's contact, you need to declare a Intent Filters, this Intent Filters to know how to deal with the view action and represent a person's uri,intent Filters generally defined in Androidmanifest.xml.

You can use Broadcastreceiver to make your app respond to an external event. Broadcastreceiver cannot generate UI, which means it is not transparent to the user and is invisible to the user. Broadcastreceiver through Notificationmanager to inform the user that these things have happened! Broadcastreceiver can be registered either in the Androidmanifest.xml or in the running code using Context.registerreceivers (). As soon as the event arrives, even if the program does not start, the system starts the program when it is needed. Various applications can also broadcast their own intent broadcasts to other applications by using Contest.sendbroadcast ().

A Service is a program that can run for a long time, but he does not have a user interface. Background songs continue to play, this play is to play the music service to control. A service can be started by StartService (Intent service), and a service can be bound through Content.bindservice ().

Content Provider
A program can expose its own data through an ContentProvider abstraction interface. The outside world through this set of standard child Chair interface and the inside of the program for interactive information. Access to read, delete and other operations! (Of course there are restrictions on the appropriate permissions)

Query (uri,string[],string,string[],string):
Querying data with Query keywords
Insert (uri,contentvalues):
Inserts a set of data into a specified place
Update (uri,contentvalues,string,string[]):
Update data
Delete (uri,string,string[]):
Delete data

Setcontentview (R.layout.main) is responsible for the current activity associated with Main.xml.

LinearLayout Layoutmain = new LinearLayout (this);
For convenience, build a layout yourself
Layoutmain.setorientation (linearlayout.horionzontal);
Sets the layout direction of elements added to this linearlayout in the vertical direction
Setcontentview (Layoutmain);
Associate the Layoutmain we built with this activity.

Layoutinflater inflate = (layoutinflater) getsystem.service (Context.layout_inflater_service)
Get a Layoutinflater object. This object can parse the layout file of the XML and generate a view.

Relativelayout layoutleft = (relativelayout) inflate.inflate (r.layout.left,null);
Call the inflate method to parse the Left.xml and generate a relativelayout layout.

Relativelayout.layoutparams Relparam = new Relativelayout.layoutparams (RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
Generates a relativelayout applicable layoutparams.

Layoutmain.addview (layoutleft,100,100)
Add layout to Layoutmain, where the first parameter is the view added, the second parameter is the height of the view, and the third is the width.

Layoutmain.addview (Layoutright,relparam)
Add Layoutright to Layoutmain, the second parameter is Relativelayout.layoutparams

Layoutinflater

This class is used to transform the layout file of XML into a class of view. For performance reasons, generating a view class from an XML layout file is done during the build phase of the application, not during the application run phase. The typical use process is changed in the OnCreate method of the activity, the code is as follows:
Layoutinflater inflate = (layoutinflater) getsystemservice (Context.layout_inflater_service);
LinearLayout layout = (linearlayout) inflate.inflate (r.layout.ex01_05,null);
The Layoutinflater class is obtained by means of the Getsystemservice method and cannot be instantiated directly. This class is responsible for instantiating an XML layout file so that it can be applied to XML-defined components in code.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Android Learning Note No.5

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.