Eclipse Content Assist 不适用于 Android

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4107515/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 15:17:40  来源:igfitidea点击:

Eclipse Content Assist not working with Android

androideclipsemethodscontent-assist

提问by EraserheadIRL

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.

我不确定这是我安装的 Eclipse (Helios) 和 Android SDK 或其他东西的问题,但 Eclipse Content Assist 不建议 Android 类的对象方法。

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?

例如,如果我创建一个简单的程序并添加一个 Button btn,当我使用带有内容辅助 (Ctrl + Space) 或 Word Completion (Alt + /) 的 btn 方法 setBackgroundResource(int) 时,它们都没有任何建议。如果我输入 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)

    }
}

采纳答案by EraserheadIRL

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!

啊,找到问题了,归结为工作区出了问题,创建了一个新的工作区并复制了我的项目,一切又正常了!

回答by Tony D

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.

移动到 Juno 4.2.0 后遇到了同样的问题。这是对我有用的:首选项>Java>编辑器>内容辅助>高级。确保勾选“Java Proposals”。

Not sure why it wasn't checked by default.

不知道为什么默认情况下没有选中它。

回答by NickT

You need to delete

你需要删除

   Button btn = Button(this);
   btn.(Ctrl + Space)

instead have

而是有

Button btn = (Button) findViewById(R.id.yourbuttonid);

(where yourbuttonid is whatever id you gave it in the XML, the assist will come to help you once you've typed the '.')

(其中 yourbuttonid 是您在 XML 中提供的任何 id,一旦您输入了“.”,帮助就会帮助您)

then when you type

然后当你输入

you should get the assist as soon as you've typed the '.'

您应该在输入“.”后立即获得帮助。

回答by Felix

Quote from http://d.android.com/sdk/eclipse-adt.html:

引自http://d.android.com/sdk/eclipse-adt.html

Caution:There are known issues with the ADT plugin running with Eclipse 3.6. Please stay on 3.5 until further notice.

注意:与 Eclipse 3.6 一起运行的 ADT 插件存在已知问题。请留在 3.5 直至另行通知。

回答by Dharmesh

Follow following step :

请按照以下步骤操作:

  1. Click on Preferences
  2. Select Java
  3. Click on Editor
  4. Content Assist and paste "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz." (note the dot after z) into the "Auto activation triggers for Java:" field.
  1. 单击首选项
  2. 选择 Java
  3. 点击编辑器
  4. 内容协助并粘贴“ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz”。(注意 z 后面的点)进入“Java 的自动激活触发器:”字段。