Crazy Android android self-learning notes, Android android self-learning

Source: Internet
Author: User

Crazy Android android self-learning notes, Android android self-learning

Required self-learning tools for developers:

Google Search: www.yundou.info

Android development documentation (English) Doc http://www.phoned.cn/docs/reference/android/view/View.html

Android original development documentation (English) Doc http://www.phoned.cn/docs.zip because Google was blocked webpage-related Google API can not be called to open the very card is recommended for network disconnection or FQ after use.

View component:

The vast majority of basic android controls are included in the android. widget package, android. view, and its sub-packages.

All the basic UI components inherit the View class, and the view is a blank panel.

 

ViewGroup has the view function, which is usually used as the view container, and is an abstract class. In order to reduce method duplication, the subclass of ViewGroup is usually used as the container.

 

ViewGroup uses its internal class LayoutParams and MarginLayoutParams to control the component layout in its container.

 

Developers can inherit the View class and implement its methods to customize personalized UI components. Generally, the basic implementation of View constructor is rewritten.

 

Class that inherits the View to override its method. The object generated by this class will generate the corresponding shape or effect according to the override method.

If you cannot find the created control when using the R Reference control or file, check whether the imported R file is the R file of the current package.

//////////////////////////////////////// //////////////////////////////////////// //////////////////////

December 25, 2015

Further exploration layout:

 

LinearLayout: streaming layout. components can be arranged in horizontal or vertical order, and the components are pushed to each other. Due to limited screen size, sometimes some controls are pushed out of the screen and cannot be seen.

 

In the GridView grid layout, add the View control after specifying the row and column ,.

 

TableLayout table layout. You do not need to specify a row or column. After adding a row, add a child control to the row control.

 

FrameLayout frame layout. Each control is superimposed in the order of loading.

 

RelativeLayout relationship layout. The positions of each control are placed by the positions of other controls as a reference.

 

AbsoluteLayout is an absolute layout. The developer determines the position of the control and strictly places the control according to the x and y coordinates.

 

//////////////////////////////////////// //////////////////////////////////////// //////////////////////

December 26, 2015

In-depth Activity

 

A large number of activities form the Activity stack. The Activity of the current Activity is at the top of the stack.

 

The inheritance relationship diagram shows that Activity indirectly inherits base classes such as context, contextwrapper, and contextthemewrapper.

 

What is callback: The call behavior that will occur at a specific time, such as the callback function. A calls B to process related transactions. B needs A to provide A transaction processing function C when processing transactions. C is called A callback function, why does A not allow B to process it directly? In the process, B may not only process transactions of A, but also other types of transactions, some underlying implementation logic is consistent in the Process of processing various types of transactions, so B is encapsulated to reduce the redundant underlying implementation code. For a general program architecture, the program completes the general functions and processes of the entire application. However, at a specific point, you need to execute the developer-defined Code related to the software business, this Code varies from person to person, and the general program architecture cannot complete this code.

 

After the internal logic of the program is executed, you need to call the developer-defined functions or code to implement specific functions. There are two methods to compile the code for this function: one is to rewrite the callback method of the new interface to embed its own code. Another method is to inherit the abstract or non-abstract class methods of the base class, and rewrite the abstract or non-abstract class methods to embed the code.

 

//////////////////////////////////////// //////////////////////////////////////// /// // December 27, 2015

Understand intent Problems

 

Android uses the same intent model to encapsulate the startup between modules, providing a unified programming model for each module component.

ComponentName (A1, A2);

The A1 parameter represents the package corresponding to A1. A1 can be String or Context.

The A2 parameter represents a component, and A2 can be a String or a class.

 

The action and category attributes of Intent are a method for setting static strings. The action method represents the actions that intent needs to complete (open, view, and so on). The category method provides additional information for action.

 

After Intent sets the method of combining category and action, it only defines the intent behavior and additional information of this behavior. It does not specify the object that executes this behavior, and controls the execution object through intent-filter, configure the Intent-filter of the Activity in Manifest, and the Activity may be started.

 

The intent-filter is used to specify the operator of the action, thus cutting off the bond between the behavior and the performer, and the relationship between the behavior and the performer is pluggable. This design reduces the Coupling Degree of the program.

 

//////////////////////////////////////// //////////////////////////////////////// //////////////////////

April December 29, 2015 (add chapter)

Android Resource Operations

Resources stored in the res directory under the Android directory are automatically indexed in the R file and can be directly referenced in the code. Assets is also the directory for storing resources. They store Native Resources that android cannot directly access. You need to use AssetsManager to read binary streams.

 

In XML code, you can use the name tag to customize the resource name in the XML resource file in addition to the system-defined Resource name.

 

 

Dimensions, colors, and string resources are defined in the value folder under res. The format for referencing resources using the @ symbol is as follows: @ string/title refers to the value of the item whose name is title in the string file of value.

 

An array in an XML resource, which is defined in the XML root tag <resource> in three Arrays: <array> common <string-array> string <integer-array> integer array.

 

The root tag <layer-list> is the XML declaration format of LayerDrawable. It contains the Drawable object (drawable = XXX) and can contain multiple Drawable objects. The order of drawing is based on the index size.

 

Five resource effects controls: StateListDrawable, LayerDrawable, ShapeDrawabe, ClipDrawable, and AnimationDrawable.

 

The StateListDrawable root tag <seloctor> is used when the control event changes.

LayerDrawable root label <Layer> draws a Graph Based on the Drawable object.

ShapeDrawable root label <Shape> sets the visual effect of the control, such as rounded corner, fill, edge, and gradient.

The ClipDrawable root tag <Clip> intercepts fragments at a specific position in the image.

The AnimationDrawable root tag <set> sets an animation resource.

 

Original XML: saves some initialization parameters or a small amount of configuration information. A large amount of information can be recorded using SQLite.

Requirement: a file with XML syntax.

Use the XML parsing XmlResourceParser method getXml (int id) to obtain the XmlPullParser object for XML-related operations.

The openRawResource method of the InputStream class can be used to obtain the XML input stream.

 

The menu resource./res/menu root label <menu> sets the menu content by setting its embedded element items.

By Rewriting the context menu method, onCreateContextMenu can load the menu resource file as a context menu, or use it elsewhere, in a similar way.

 

Define theme resources in Android.

Control style control: the root tag <resource> adds attributes through the sub-tag <style>. Sub-label <style> You can specify the style name by name and the inheritance item by parent.

Activity topic control: the XML format of the Activity topic is similar to that of style control. Most item items are written in the form of system function android: WindowXXX.

You can set a topic for a single activity by using the setTheme method of the activity. You can set a topic in manifest.

 

Attribute resource, root tag <resource>, attr is a sub-element, and declare-styleable is a set of attributes.

The AttributeSet method is used in the code to obtain attributes.

 

Attribute manages the attributes of an object and standardizes object attributes.

 

When using attributes, import the package of the attribute in the project XML layout. Namespace: xmlns: xxx.android.com/apk/res/packge

 

Android program internationalization main class: ResourceBundle, locale, translation files stored in the form of KEY-VAR key-value pairs, through native2veascii to convert it to Unicode format.

 

Android programs are internationalized. You can also use res to create strings for folders named in different languages (value-zh-rCN. xml Key-value pairs (<string name = "OK"> good </string>. ,

 

//////////////////////////////////////// //////////////////////////////////////// //////////////////////

Graphics and image processing (mainly manual)

 

Bitmap represents a Bitmap. BitmapDrawable encapsulates Bitmap objects.

To access images in a path other than the android program itself, you must use BitmapFactory to parse and create a bitmap object.

Creating a bitmap Object usually occupies the device memory. If the isRecycle () method of the bitmap object method is used to determine whether the recycle () method has been recycled, It is forcibly recycled.

Override the onDraw method to implement painting by inheriting the view component.

Canvas represents the Canvas, and paint represents the paint brush. Different methods can be used to achieve different effects of painting.

Path represents any image connected by any number of lines. It can link N points into a path in the view in advance, and then draw a graph along the path using the drawPath method of canvas.

PathEffect defines the rendering effect.

Matrix is a Matrix tool class provided by android. It is used with other APIs to control the transformation of graphic components.

 

//////////////////////////////////////// //////////////////////////////////////// //////////////////////

April January 1, 2016 (add two chapters)

Android data is stored in IO streams

The SharedPreferences interface is used to save a small amount of information, such as configuration information and software-related external storage.

SharedPreferences provides a series of read and write operations for external stored files.

The internal interface Editor of SharedPreferences provides the data writing and clearing methods.

SharedPreferences is an interface and cannot be used to generate its objects using the new method. If you forcibly use the new method to generate its objects, it is written as an internal class. Use context. getSharedPreferences (); to obtain the object.

Context provides a set of IO file streams for reading files in the data folder of the current application: openFileInput openFileOutput.

Read/write SD card files: Environment getExternalStorageState (); Judge the SD card status.

GetExternalStorageDirectory () to get the SD card directory.

Use the FileInputStream FileOutputStream FileReader FileWriter method to read and write files.

 

Note: it is not enough to understand the content of the book, but it is not enough to understand the content of the book. The engineering materials need to understand and practice while learning it, and if you cannot stick to it, you will soon forget to do more. January 2, 2016

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.