Eclipse Content Assist 不适用于 Android
我不确定这是我安装 Eclipse (Helios) 和 Android SDK 的问题还是其他问题,但 Eclipse Content Assist 不建议针对 Android 类使用对象方法。
例如,如果我创建一个简单的程序并添加一个按钮 btn,当我去使用 btn 方法 setBackgroundResource(int) 和内容辅助 (Ctrl + Space) 或单词完成 (Alt + /) 时,它们都没有任何建议。如果我输入 btn.(Ctrl + Space),内容辅助会列出; equals()、getClass()、hasCode()、Notify()...wait() 不显示任何 Button 方法!有人可以帮忙吗?
import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
public class HelloWorld extends Activity {
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
Button btn = Button(this);
btn.(Ctrl + Space)
}
}
I'm not sure is this is a problem with my installation of Eclipse (Helios) and Android SDK or something else but Eclipse Content Assist doesn't propose Object Methods for Android classes.
For example, if I create a simple program and add a Button btn, when I go to use the btn method setBackgroundResource(int) with Content Assist (Ctrl + Space) or Word Completion (Alt + /) neither of them have any proposals. If I type btn.(Ctrl + Space), Content Assist lists; equals(), getClass(), hasCode(), Notify()...wait(), shows none of the Button methods! Can anyone help?
import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
public class HelloWorld extends Activity {
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
Button btn = Button(this);
btn.(Ctrl + Space)
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
迁移到 Juno 4.2.0 后也遇到同样的问题。这对我有用:
首选项>Java>编辑器>内容辅助>高级。确保“Java 建议”已勾选。
不知道为什么默认情况下没有检查它。
Had this same problem after moving to Juno 4.2.0. Here's what worked for me:
Preferences>Java>Editor>Content Assist>Advanced. Make sure “Java Proposals” is ticked.
Not sure why it wasn't checked by default.
啊,发现问题了,这是工作区出了问题,创建了一个新的工作区并复制了我的项目,一切又正常了!
Ah, found the problem, it's down to something going wrong with the workspace, created a new workspace and copied over my projects, all working again!
您需要删除
而不是具有
(其中yourbuttonid是您在XML中提供的任何ID,一旦您输入“。”,帮助就会为您提供帮助),
然后当您输入时,
您应该会立即获得帮助已经输入了“.”
You need to delete
instead have
(where yourbuttonid is whatever id you gave it in the XML, the assist will come to help you once you've typed the '.')
then when you type
you should get the assist as soon as you've typed the '.'
引用自 http://d.android.com/sdk/eclipse-adt.html:
Quote from http://d.android.com/sdk/eclipse-adt.html:
按照以下步骤操作:
“ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz。” (注意
z 后的点)输入“Java 自动激活触发器:”字段。
Follow following step :
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz." (note the
dot after z) into the "Auto activation triggers for Java:" field.