The younger brother is really excited to see the series of Android blogs of other Daniel on the csdn blog. So after some ideological struggles, the younger brother finally wants to write a series of blogs. I decided to thoroughly study the android SDK documentation and share and exchange with you through blog posts. Haha, it's time to think about it!
This is the first attempt. This article mainly introduces the structure and usage of the android SDK document and the knowledge about Android in pakage index.
Okay, let's talk about it. Start it!
I. Wedge: Android SDK documentation
First, what is the android SDK documentation?
This is an idiot. However, it is still slow. I think it is worth talking about. The reason is that you are not self-evident after reading the following. The full name of the android SDK is Android software develop kit, which is the tool group for Android program development. That is to say, it is essentially a tool for everyone-just like a hammer or a wrench (no wonder the logo developed by Android is a little robot with a wrench and a hammer at its waist ). Since it is a tool and a new tool that has been quickly launched by Gu Ge in recent years, if you want us who are interested in it to use it freely, there must be a detailed instruction to explain where it is used, how it is used, and how it is best to use it. The android SDK documentation plays this role: it contains components used in almost all situations of the tool (that is, various types included in the android SDK) ui build, GPS module call, database operation, hardware call, and so on; it allows you to know how to use various tool components-methods and fields of various types have almost been covered. Basically, you can see how to use this class; it allows you to know how to use the tool best-which methods have expired, it will tell you the special attributes of some classes, it will teach you how to best use (such as Android. app. the startforeground (int id, Notification) method of the service class teaches me to use the Java reflection mechanism to call the final method that the parent class cannot inherit from the subclass ). Here, we can describe the android SDK documentation as follows: An android SDK user manual.
Second, where can I see the SDK documentation?
There are two ways to view SDK documents: Online Web browsing and offline Document Browsing.
Online address: pai.android.com)
Offline viewing does not require you to download the document package separately, because if you chose to download the full downloaded Android SDK, the document will be downloaded to the local device. Generally, the docsfolder in the root directory of the andorid sdkcontains an index.html file. Open it to view the homepage of the SDK document.
Personally, it is recommended to go offline. Although it may not be the latest version of the document, it is always better than being quickly tortured by the wall.
Third, document importance.
When I first started learning Java, I did a very bad thing: I saw system. Out. println ("Hello world! "); I want to know what the system is, so I went to the Internet to search for it-but it took a lot of time and I also read some articles, however, we still cannot have a systematic understanding of the system-or later we learned about the Java documentation and downloaded the Java documentation (the Java documentation is not included in the SDK by default) after reading it, I can understand it completely-What a shame! Well, you should understand the importance of the SDK documentation without having to mention it: the documentation is officially provided, so it has unparalleled authority. The documentation serves as an illustration, therefore, what you want to know will be provided to you on "tracking". Because documents are very important, they are very important.I suggest you develop a habit. When you encounter any questions in the future, you should first look up the SDK documentation and then go to Baidu and Google: in this way, you can train yourself to understand e.TextCapability, 2It will also make you more impressed.
4. Recommended documents
1. view online Java2 Chinese documents
2. Official Google C ++ specifications
3. Google map user manual in Android
4. About javadoc
Ii. Start and Sublimation: Basic knowledge of the android SDK documentation
To quickly and skillfully use the android SDK documentation, you must first understand this topic. So next I will share with you the basic knowledge about the structure and content of the android SDK documentation.
1. Android SDK document structure
Area 1: tab bar. Each tag represents different types of help contained in the document.
Home: Welcome Page
SDK: provides an overview of SDK versions and provides guidance on the establishment of development environments.
Dev guide: provides preliminary guidance on development. Some useful examples are here.
Reference: similar to the android API document of the Java API documentation, we will always pay attention to it in the future (that is, the reference homepage)
Resources video and blog: it is hard to enjoy some other developer support resources in our network environment.
In the future, I will mainly explore the reference section, which contains a large amount of gold. If necessary, I will look at the dev guide.
Region 2: package list in reference
For more information about each package, see here.
Area 3: Main Content browsing area of reference
Area 4: search box, mainly used to search for a class before the interface to quickly browse the reference of this class (easy to use, highly recommended !)
You can use the auto-completion feature of the search box that comes with the document to quickly search for the class you want to query. For example, if you want to search for layoutparams, you only need to enter the four letters of layo to see this class, and then click this class to directly enter the layoutparams document.
Region 5: This area is used to correspond the serial number of each API version in Android apilevel, which is easy to distinguish. For example, Version 2.2 corresponds to version 8. It is also useful for filtering classes, interfaces, and related methods.
Area 6: display areas of various types and interfaces in a package
2. Document Content
Here we will talk about the main content of reference.
For a class, the reference is related to the following parts:
(1) Important attributes. The "prefix" of the Class-public, private, abstract, and so on; The "kinship" of the Class-who inherits from, what interfaces are implemented, and what direct and indirect subclasses are implemented; historical Origins of this class-from which apilevel exists. For example, intent (for example ):
This tells us that intent is a public class and inherits from the object. It also implements parcelable and cloneable interfaces. It has a direct subclass labeledintent. In addition, intent has existed since API Level 1 (old-level figures ).
(2) class overview ). Here, we will describe the functions and properties of this class. The language is concise and powerful, which is very important and therefore must be carefully read. For example, layoutinflater's class overview:
After reading it, you will probably know that layoutinflater is a tool class that instantiates the layout information in an XML file and converts it to a view-class instance. It is also very exciting that a method for obtaining layoutinflater (in the middle of Java code) is also provided here ), it's really thoughtful (when you read the overview of the class activity, view, intent, and so on, you will even be moved to "inner niu ")!
(3) summary ). In this place, all attributes of this class (yes, that is, everything, including the attributes used in XML Code) will be generalized (usually in one sentence) description-the main purpose is to facilitate your search. This part contains the following small units:
I. The internal class of this class (Nested classes)
All internal classes of this class will be introduced here. To view the details of an internal class, click the link of the internal class to jump back to the document interface of the internal class.
Ii. xml attributes (XML attributes) that can be applied to this class)
Many children's shoes have some questions at the beginning: Where can I find the XML Attribute of a UI component? I want to set the background of linearlayout to an image. Which XML Attribute should I use? Is there any XML Attribute that can make my button more beautiful? At the beginning, I was very confused, and I was always depressed because these questions were not solved. Later, after I carefully studied the android SDK documentation, these problems will be roughly solved-because there is a dedicated section in the documentation.
Describes XML attributes. For example, the XML Attribute of imageview is described as follows:
After reading the description, do you have a lot of questions about the cloud )? In addition, you may wonder -- what is the use of the related method in the middle -- here is the focus: These related
Method is actually a related method in Java, that is to say, in Java code, the method that can change the relevant class of this attribute. For example, if you want to set an image for imageview, you canAndroid: src = "@ drawable/my_picture"When you see that the Android: SRC property also has a setimageresource (INT) method, you can also set: myimageview in Java code. setimageresource (R. drawable. my_picture );. I still remember that I had discovered this for a while.
Iii. inherited XML attributes (inherited XML attributes)
That's right, the magic XML determines that various attributes in android can be passed from the parent class to the subclass through inheritance. When you cannot find an attribute in XML attributes, you can search for it here, which is generally available.
Iv. Constant (constants)
It contains some constants of this class. A description is provided next to a constant. clicking a constant will jump to a detailed description of the constant. We recommend that you take a look at the introduction of intent, window and other important class constants. Believe me, it is awesome.
V. inherited constants (inherited constants)
A constant inherited from the parent class.
Vi. Method list (methods)
This section describes the indexing of all the methods of this class-including the public protected method and constructors method. If you want to use the private method, check the SDK source code and use reflection to obtain the method.
(4) Detailed Description
This section corresponds to the description section, and describes the XML attributes, constants, and methods in detail. Some examples are provided for your reference.
For XML attributes, we will show you the values assigned to these attributes:
Clickable must be set to a Boolean value.
Here we will provide an overview of the parameters and returned values:
Well, I admit that this part is very small. Don't be surprised. However, I think it is necessary to introduce a complete and responsible presentation, so I put this part on. After reading this part, please leave the brick in the comments section. If the brick quality is good, I will add it to my favorites!
3. High Tide: Android package Introduction
When you open the reference document, you first see the android package in the pakage index. This package may not have been visited by many children's shoes. But I have to tell you that the content in this package is an 8-star shopping bag! Drool, right? Well, let's take a look at the stuff in it (this package contains something relatively simple structure, so it's all described at once ).
Android package
Classes contained in this package:
(1) manifest
Okay, you must have thought of androidmanifest. XML in the android project file.
File, and conjecture that it has an "ambiguous" relationship with this class. Bingo! In fact, they are closely related: manifest instances generally use androidmanifest. the XML file is generated after XML parsing (if you cannot understand it for the time being, you can think of layoutinflater, a very familiar process of parsing layout in XML into a view class instance ). Androidmanifest is saved in the manifest instance. XML Information (activity attribute information, permission usage information) to help the system process your application-for example, which activity should be used as the starting activity, whether or not the horizontal display of the activity is prohibited, and so on.
(2) manifest. Permission and manifest. permission_group
The main members of these two classes are strings. With these strings, android can grant and manage application permissions.
If you have used Google APIs in the android program, or you have studied how to call a camera to take photos, you will not be unfamiliar with these codes:
1 |
<Uses-Permission Android: Name = "android. Permission. access_fine_location"> </uses-Permission> |
2 |
<Uses-Permission Android: Name = "android. Permission. Internet"> </uses-Permission> |
3 |
<Uses-Permission Android: Name = "android. Permission. Camera"> </uses-Permission> |
The Code declares the permission to use your application-the permission to use the function, the permission to use the network, and the permission to use the hardware camera-if you do not declare the permission, the application will be terminated unexpectedly. These statements declared in androidmanifest. XML will also be parsed as string objects in manifest. Permission and manifest. permission_group during application loading.
(3) R and all its subclasses (from R. anim to R. XML)
Here, R represents resource, which means resource. It is hard to guess that these classes constitute a set of built-in resources of the Android system.
R. anim: the android animation file that comes with the system, including the familiar fade_in and fade_out
R. array: the system comes with an array.
R. ATTR: this class is very powerful, because all XML attributes in Android are found here -- Needless to say, the common layout_height and layout_width, some XML attributes that we will not encounter are described here. So if you see an XML Attribute that you have never heard of in other people's code in the future, check it here-believe me, you will not be disappointed!
R. bool: Very strange class, because it has nothing but a constructor-what is it? Hope you can answer this question!
R. color: The color resources that are usually called by some systems (it should be the values of some RGB color codes). Of course, you can also call them in your application, so that it can maintain the same color style as the Android system.
R. DEMON: after reading the document, I only know that it is related to the android program launcher (Android launcher)-because it has an attribute of app_icon_size, which defines the standard application Icon size.
R. drawable: Some drawable resources used by the system.
R. ID: the ID of the component that the system program calls.
R. Integer: There are some constants, and they are used to control the duration of Android animation-long, medium, short (config_longanimtime, config_mediumanimtime, config_shortanimtime ). You can use these ready-made durations in your custom animation so that your animation conforms to the local features of Android.
R. Layout: The layout files that are frequently used in the system are all here. In normal times, we often use the Android. R. layout. simple_list_item_single_choice function as a spinner.
R. plurals: Like bool, wait for the explanation from the top.
R. Raw: No member is pointed out in the document, but according to the name, I guess it is a collection of some Native Resources of the system (such as the sound file of the on/off server ).
R. String: some system-called string objects.
R. Style: some commonly used Android style files (theme files) in the system ).
I am very happy to write it here, hoping to solve some of your child shoes.
Iv. Conclusion: some statements
As this is the first article, the things mentioned may be a little too small for the ox, but to take care of the children's shoes that have just started, add some of the most basic knowledge to form the first "Forward pass ". For those who are familiar with the above basics, let's take a look at the part about the android package. It should be helpful. In addition, there are a few examples in this bag that I have not thoroughly studied, hope you can help us solve this problem. I am very grateful!
As for reprinting, you may feel good about it. If you have any help, let's stick to it! In addition, please note that it is out of csdn (it doesn't matter if it is not mentioned, but csdn must be noted, hope to understand ).
Well, Thank You: Ferry, Gu Ge.
Thank you for watching.
If you have any questions, please click it!