Eclipse Content Assist not working with Android
Asked Answered
Y

5

12

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)

    }
}
Yurik answered 5/11, 2010 at 15:43 Comment(0)
Y
8

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!

Yurik answered 14/12, 2010 at 16:57 Comment(1)
Thanks! The same problem occurred to me when I switched to Eclipse 4.2 (Juno) from 3.7 (Indigo). After copying them in, all I needed to do was import them as existing projects.Manos
B
74

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.

Barty answered 31/8, 2012 at 14:17 Comment(4)
I love you. Seriously. Tons of time saved!Trask
That did it for me. I needed to reopen the editor for that XML file and wah-la, your solution worked wonders.Inesita
Me too. Such a simple little thing bugged me like hellRosebay
Happens to me every time I clean the project.Oxysalt
Y
8

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!

Yurik answered 14/12, 2010 at 16:57 Comment(1)
Thanks! The same problem occurred to me when I switched to Eclipse 4.2 (Juno) from 3.7 (Indigo). After copying them in, all I needed to do was import them as existing projects.Manos
C
1

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

Chipman answered 5/11, 2010 at 16:2 Comment(2)
Or Button btn = new Button(this);Cleavers
Thanks NickT for your help, I've given that a go but no joy, so if you see the Button methods and I don't then there must be something wrong with my Eclipse install, I switched to Eclipse 3.5 and still had the same problem!Yurik
T
1

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.

Terina answered 5/11, 2010 at 17:9 Comment(1)
Thanks Felix, I've switched to Eclipse 3.5 and re-installed Android SDK, but again when I type btn.(Ctrl + Space) content assist doesn't list any Button methods. Also if I create the Button btn by linking it to an XML Button using Button btn = (Button) findViewById(R.id.Button01) content assist still doesn't show any Button Methods after typing "btn" + "." + (Ctrl + Space) it just lists a number of basic object methods. Does it work for anyone else?Yurik
H
0

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.
Hooks answered 28/7, 2015 at 6:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.