Android Learning Notes

Source: Internet
Author: User

First, the basic knowledge
Android Four components: Activity,service,broadcast Receiver,contentprovider
Activity: an active interface;
Service: Background program with no active interface
Broadcast Receiver: System broadcast
ContentProvider: Implementing Data sharing

Intent: For communication between activity components
Avd:android Virtual Devices Virtualization Appliance
(The AVD Device selection 3.2*QVGA (ADP2) (320*480:mdpi) screen is more appropriate)
Adb:android Debug Bridge Debug Tool
Ddms:dalvik Debug Monitor Service

File directory:
SRC: saving Java source code
Gen: Save the automatically generated R resource class folder
R.java:java A resource index class between a source file and a reference resource
Assets: Saving the original resource file
Res: Save the resource file, layout file, values to save the constant value
String.xml: Declaring a string constant used by the system
Drawable: Save resources such as pictures
DRAWABLE-HDPI: Represents high screen density picture drawable-mdpi: Medium screen density drawable-ldpi: low-level screen density
Androidmanifest.xml: All components must be declared in this file

Second, the user interface
Common layout:
LinearLayout (linear layout), Framelayout (frame layout), tablelayout (table layout),
Relativelayout (relative layout), Absolutelayout (absolute layout)
Framelayout: Cascade Arrangement, the first added component is placed at the bottom, the last component added at the top,
The previous layer overrides the next layer of control.

Layout properties:
Android:layout_width= "Match_parent" means the width of the control is full line
Android:layout_height= "Wrap_content" indicates that the control is stretched to be able to display content
Android:layout_weight to specify the size of the control using a proportional method
Android:layout_gravity is used to specify how the control is aligned in the layout
Android:hint= "Type something here" for displaying prompt content in EditText

Relativelayout Properties:
The Android:layout_above property allows a control to be located above another control
Android:layout_below means that a control is placed below another control
Android:layout_torightof means to have one control on the right side of another control

View:
ListView (List view), GridView (grid view), Gallery (Gallery view), WebView (Network view)
Surfaceview (animation view)
dialog box:
Datapickerdialog (Date dialog box), Timepickerdialog (Time dialog box), Alertdialog (System prompt dialog box)
Menu:
Options menu, ContextMenu (Context menu), submenu (submenu)
Third, Activity
Activity life cycle:
OnCreate (): Create activity, load layout
OnStart (): from invisible to visible
Onresume (): Becomes available to interact with the user
OnPause (): Called when the system is ready to start or resume another activity?
OnStop (): Becomes invisible
OnDestroy (): Destroyed
Onrestart (): Restart
Iv. Intent
1. Explicit intent jumps between activities (remember to register a second activity in Androidmanifest.xml)
Intent Intent = new Intent (firstactivity.this, Secondactivity.class);
StartActivity (Intent);

2. Implicit intent jumps between activities (remember to register a second activity in Androidmanifest.xml)

Wu, Broadcasreceiver
There are generally two ways to register a broadcast, which is called dynamic Registration in code, and registration in Androidmanifest.xml is called static registration.
Dynamic registration:
1. New class inherits Broadcastreceiver, and overrides receive ();
2. In the activity OnCreate (), instantiate Intentfilter, and Addaction, and then register with Registerreceiver ();
3. Dynamically registered broadcast receivers must be unregistered only, can be implemented in the OnDestroy () method by calling the Unregisterreceiver () method.
Static registration:
1. Create a new class to inherit Broadcastreceiver, overriding the OnReceive () method;
2. Register the Broadcastreceiver with the Androidmanifest and write the broadcast information contained in the <intent-filter>;
3. Use <uses-permission> declaration authority in Androidmanifest;
3. In the activity, instantiate the intent and issue the broadcast with Sendbroadcast ().

Because broadcasts are passed using Intent, you can carry some data to the broadcast receiver in Intent.
How do I use intent to deliver data in a broadcast?

Android Learning Notes

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.