"Go" Android How to view the Android API source code and support package source code in eclipse

Source: Internet
Author: User

Original URL: http://blog.csdn.net/vipzjyno1/article/details/22954775

When we read the Android API Development documentation, each of the above classes, as well as the various methods of the class, are all methods and controls that have been written, but we are just moving in, not knowing how it works and how it is implemented. Android system is open source, so the official Google in each release of a version of the API will release its corresponding source code, so that we can learn more about the Android API implementation process, this is the charm of open source. If we understand the development process from the point of view of API source, then we will have more in-depth experience for us as a developer, which is helpful for future software development.

For example, to view activity's source code,

You can also see how the system method implements a process,

One method to invoke when each activity setting interface is: Setcontentview (r.layout. Welcome);

From the code we can see, this method is actually the system is divided into a simplified version of our use, we can also follow the source code inside the

GetWindow (). Setcontentview (r.layout. Welcome);

The effect of this is the same.

In the button controls such as the system-provided buttons:

Do not see do not know a see, originally its parent class is TextView, then we look at the source of TextView control:

It can be found that its parent class is view, and Android's system controls are inherited from the view class, so when we want to customize the control, we can inherit the view to make the control we want.

In eclipse you need to see the source code of a class, press CTRL and then click the class or method you want to view, it will open the corresponding class file, but this is based on the configuration of the source of the case will be opened, let's go to see how to configure:

One. Android API source code

1. First download the corresponding version API under the SDK source code source for Android SDK

2. Then find the directory where you installed the SDK, my SDK directory path is: C:\Users\Administrator\android-sdks

Find the corresponding Sources folder for each version

It's the source file that corresponds to the version you downloaded.

Let's take 4.3来 as an example (android-19 is the corresponding 4.3)

Find directory path

C:\Users\Administrator\android-sdks\sources\android-19

Then right-click on your project, select the properties at the bottom of the menu---Java buld Path---Libraries---android 4.3---android.jar

Click Edit,

In the input box shown in front of your source directory, then the project will automatically update, then you can view the source code.

Second: To view the corresponding support expansion package source code

Let's take Android-support-v4.jar as an example.

1. First download the Android support library under the SDK, which contains the latest version of the expansion pack

Then find the extension package to the directory, this is the V4 package path, my path is: C:\Users\Administrator\android-sdks\extras\android\support\v4\src

Under the Lib file of your project, There will be a Android-support-v4.jar rack package, in which the file is created named: Android-support-v4.jar.properties, (other V7 what the rack package is similar to, after the original rack package name plus. Properties can be) as shown in:

My support V4 's rack package source path is C:\USERS\ADMINISTRATOR\ANDROID-SDKS\EXTRAS\\ANDROID\SUPPORT\V4\SRC

Then open the file you created, enter the location of the source of your package:

If you are under Windows operating system, enter the path: C:\\USERS\\ADMINISTRATOR\\ANDROID-SDKS\\EXTRAS\\ANDROID\\SUPPORT\\V4\\SRC

Format in ndroid-support-v4.jar.properties file: src = c:\\users\\administrator\\android-sdks\\extras\\android\\support\\v4 \\src

The next step is to close the project, and then in Open,

Then I want to see the fragment of the V4 rack package, which is by holding down CTRL while clicking Fragment, and viewing the

Through the source code to learn more about the implementation process of the API, you can let us have more in-depth understanding of Android.

"Go" Android How to view the Android API source code and support package source code in eclipse

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.