Eclipse Content Assist not working with Android

2019-02-06 09:00发布

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)

    }
}

5条回答
▲ chillily
2楼-- · 2019-02-06 09:21

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.
查看更多
小情绪 Triste *
3楼-- · 2019-02-06 09:23

Quote from 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.

查看更多
倾城 Initia
4楼-- · 2019-02-06 09:30

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!

查看更多
forever°为你锁心
5楼-- · 2019-02-06 09:35

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.

查看更多
\"骚年 ilove
6楼-- · 2019-02-06 09:44

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 '.')

then when you type

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

查看更多
登录 后发表回答