在哪里可以找到Android SDK中类的源代码? [英] Where can I find the source code for classes in the Android SDK?

查看:118
本文介绍了在哪里可以找到Android SDK中类的源代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试查找Android SDK类的源代码,例如View,Canvas和Bundle.在哪里可以找到这些类的源代码,甚至有可能吗?

I'm trying to find the source code for Android SDK classes such as View, Canvas, and Bundle. Where can I find the source code for these classes and is it even possible?

推荐答案

可以通过使用SDK Manager下载SDK源代码来查看内置类(属于Android SDK的类)的源代码.

The source code for built-in classes (those that are part of the Android SDK) can be viewed by downloading the SDK source code using the SDK Manager.

在Android Studio中,导航至工具-> Android-> SDK管理器.打开后,您需要下载Android SDK的源代码,如下所示.

From within Android Studio, navigate to Tools -> Android -> SDK Manager. Once open, you'll need to download the Sources for Android SDK as shown below.

一旦下载了源代码,就可以在SDK的"sources"文件夹中找到源代码(无论您计算机上的何处).在下面,我添加了一个图像,以显示在SDK源文件中可以找到View.java类的位置.要在SDK中找到其他类,请使用包名称作为它们在文件夹结构中位置的提示来导航至它们.(例如android.app.Activity-> android/app/Activity.java).

Once you have the sources downloaded, you can find the source code inside of the "sources" folder of your SDK (wherever that may be on your computer). Below I've added an image to show where you would find the View.java class inside of the SDK source files. To find other classes in the SDK, navigate to them using the package name as a hint to their location in the folder structure. (e.g. android.app.Activity -> android/app/Activity.java).

此外,如果您下载特定版本的源代码,然后在build.gradle文件中将该版本设置为compileSdkVersion版本,则可以通过单击类名的命令直接在Android Studio中访问源代码.因此,如果您下载API 21的源代码,然后将compileSdkVersion设置为API 21(如下所示),则无需导航文件系统即可找到文件.

Also, if you download the source code for a specific version, then make that version your compileSdkVersion version in your build.gradle file, you can access source code from directly within Android studio by command clicking on the class name. So if you download the sources for API 21, then set your compileSdkVersion to be API 21 as shown below, you won't have to navigate your file system to find the file.

这篇关于在哪里可以找到Android SDK中类的源代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆