1. 下载android.jar对于版本的source code
http://git.source.android.com/?p=platform/frameworks/base.git;a=snapshot;h=android-2.3.1_r1;sf=tgz
URL中的android-2.3.1_r1替换成任意你需要版本的sdk tag名称即可。点击tage名称列表查看所有有效的tag名称。
利用这个URL下载到了源代码压缩包base-android-2.3.1_r1-3c67ae1.tar.gz。
2. 设置android.jar源代码目录
在SDK安装目录\android-sdk-windows\platforms\android-9中创建sources目录
解压base-android-2.3.1_r1-3c67ae1.tar.gz,拷贝base-android-2.3.1_r1-3c67ae1\core\java下的文件到刚刚创建的sources目录
在Eclipse中,右键点击项目properties->Java Build Path->Libraries->Andriod 2.3.1
展开Andriod 2.3.1->android.jar->source attachment,点击Edit 按钮,设置android.jar对应的源代码目录。
注,如果以上设置完成之后还是无法显示.
如果错误提示为:
Could not open the editor: The editor class could not be instantiated. This usually indicates a missing no-arg constructor or that the editor's class name was mistyped in plugin.xml.
则说明你 .class文件的查看方式有问题,可能自己进行过自定义设置
进入
preferences--general--Editors--File associations
选中*.class 重置下面的associated editors 为class file viewer
其他
eclipse 的单词拼写检查有点弱智,有时非常烦,禁掉它。
General --> Editors --> Text Editors --> Spelling
去掉 Enable spell checking 前面的勾