views:

1559

answers:

5

When adding an activity to an existing Android project, I manually create a new class - is that the best / preferred way? How do others handle that?

+3  A: 

I just use the "New Class" dialog in Eclipse and set the base class as Activity. I'm not aware of any other way to do this. What other method would you expect to be available?

mbaird
Just curious if maybe there was a plugin that automated some of it or provided a step-by-step wizard.
Eno
A: 

I use New Class too... i think there aren't other solutions right now

Andrea
A: 

There is no tool, that I know of, which is used specifically create activity classes. Just using the 'New Class' option under Eclipse and setting the base class to 'Activity'.

Thought here is a wizard like tool when creating/editing the xml layout that are used by an activity. To use this tool to create a xml layout use the option under 'New' of 'Android XML File'. This tool will allow you to create some of the basic layout of the view.

Jason D.
A: 

but creating through new class doesnt generate R Class which is the autogenerated class for each activity thus it create problem if we want to use R class in our activity class.. how do you guys deal with this

Hrishi
A: 

The R.* classes are generated dynamically. I leave the "Build automatically" option on in the Project menu so that mine R.* classes are always up-to-date.

Additionally, when creating new Activities, I copy and rename old ones, especially if they are similar to the new Activity that I need because Eclipse renames everything for you.

Otherwise, as others have said, the File->New->Class command works well and will build your file for you including templates for required methods based on your class, its inheritance and interfaces.

Jerry Brady