当重写Android方法时,Eclipse会插入arg0,arg1等而不是正确的参数名称 [英] Eclipse inserting arg0, arg1 etc. instead of proper parameter names when overriding Android methods

查看:250
本文介绍了当重写Android方法时,Eclipse会插入arg0,arg1等而不是正确的参数名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我从Eclipse中的Android类重写方法时,我得到了无用的参数名称,如arg0,arg1等。例如,当从重写方法时,SQLiteOpenHelper I获取:

When I override methods from the Android classes in Eclipse, I get useless parameter names like "arg0", "arg1" etc. For example when overriding methods from SQLiteOpenHelper I get:

@Override
public void onCreate(SQLiteDatabase arg0) {
    // TODO Auto-generated method stub
}

@Override
public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) {
    // TODO Auto-generated method stub
}

我发现了关于此的各种帖子,但没有一个可接受的解决方案似乎对我有用。这也很奇怪,因为它似乎只在某些时候发生。例如,上述测试中的构造函数具有正确命名的参数。

I've found various posts about this but none of the accepted solutions seem to work for me. It is also strange because it only seems to happen some of the time. For example the constructors in the above test had correctly named parameters.

获得Android SDK管理器中安装的Android SDK文档对于Android 4.4.2。我是否仍然需要以某种方式手动附加文档(甚至来源?)才能可靠地工作,如果是这样,我该怎么做?

I have got "Documentation for Android SDK" installed in the Android SDK Manager for Android 4.4.2. Do I still need to manually attach the docs (or even source?) somehow for this to work reliably, and if so how do I go about this?

谢谢!

推荐答案

正如评论中提到的@ greg-449,需要附加 Android来源工作。

As @greg-449 mentioned in the comments, the Android source needs to be attached for this to work.

按照这个链接似乎解决了这个问题。

Following the steps in this link seems to fix this.

如果链接是在将来打破,步骤是:

In case the link is broken in future, the steps are:


  1. 使用SDK Manager下载Android SDK的来源

  1. Download "Sources for Android SDK" using the SDK Manager

在Eclipse Package Explorer中右键单击 android.jar (在 Android {version}下 node),然后单击属性

Right click android.jar in the Eclipse Package Explorer (under the Android {version} node), and click properties

在Java源附件下,输入下载的源目录的路径,该目录沿着的 {SD k} / sources / android- {version}

Under "Java Source Attachment", enter the path to the downloaded source directory which is along the lines of {sdk}/sources/android-{version}

然后我知道了:

@Override
public void onCreate(SQLiteDatabase db) {
    // TODO Auto-generated method stub
}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    // TODO Auto-generated method stub
}

更新:作为参考,Android Studio中出现了类似的问题(v0.4.2 at the写作时间)。可以通过文件 - >其他设置 - >默认项目结构附加源,选择SDKs,android平台并在Sourcepath选项卡中添加源。

UPDATE: For reference, a similar problem occurs in Android Studio (v0.4.2 at the time of writing). Sources can be attached via File -> Other Settings -> Default Project Structure, select SDKs, android platform and add the source in the "Sourcepath" tab.

这篇关于当重写Android方法时,Eclipse会插入arg0,arg1等而不是正确的参数名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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