Java – How do I drag a button in Eclipse and automatically generate an onclick method? How do I find variable/method references in Eclipse?

How do I drag a button in Eclipse and automatically generate an onclick method? How do I find variable/method references in Eclipse?… here is a solution to the problem.

How do I drag a button in Eclipse and automatically generate an onclick method? How do I find variable/method references in Eclipse?

I’m a C#/Visual Studio developer. I’m porting some of my WP7 apps to Android, and I’m pretty used to Eclipse. I’ve read some “diff” docs, but there are still some issues that need to be addressed urgently. .

In VS, I drag a button to the surface and assign a method name to onclick, and it generates the method outline for me in my source file. I don’t see how to do this in Eclipse – is that okay?

In VS, if I place the cursor over a variable or method name, I see a drop-down menu with the Go To option and the Find All References option. These are really convenient. Can I do this in Eclipse?

Solution

You’re working on an Android project in Eclipse, so my answer will be based on that. I also guess you have the Android Developer Pack plugin installed.

In Java’s ADT plugin, you can open layout.xml and view its Graph Layout. You can drag UI components there, but it won’t generate code for you to handle events.

For the second question, in Eclipse, you must right-click on a variable or method and go to the Reference menu. Or you can learn keyboard shortcuts, which will become easier.

Related Problems and Solutions