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

Source: Internet
Author: User

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 the E dit,


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, under which the file name is: Android-support-v4.jar.properties, (similar to other V7 or racks, add . Properties to the original rack package name, as shown in:

My Support V4 's rack package source path is C:\Users\Administrator\android-sdks\extras\\android\support\v4\src

after Open the file you created, enter the location of the source code for 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.

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.