tags:

views:

63

answers:

2

The only available reproducible example I can find to share with the board is the Android sample code NotePad, which is loaded into the IDE's Package Explorer as 'NotesList'.

I want to know why, in the package's NoteEditor.java, LinedEditText (extended from EditText) can't be renamed? In other words why can't I rewrite this extended class as, say, "Lined_EditText" in the two lines where the word exists, in its class name and its constructor? They are the only two locations, as far as I can determine, where the words exist in the entire package.

(There is an org.hermit.android.widgets.LinedEditText at http://moonblink.googlecode.com/svn/trunk/HermitAndroid/doc/org/hermit/android/widgets/LinedEditText.html, but this NotePad sample in the Android SDK doesn't import that class. The sample only imports android.widget.EditText .)

Thanks for any help.

+1  A: 

I don't have the example in front of me to confirm, but if this is the main class in the file, it has to match the file name.

Thus you can rename it to Lined_EditText if the filename is also renamed to Lined_EditText.java.

If you are using Eclipse (or any decent IDE), it should take care of this for you with the refactor option in the context menu.

Aaron C
Thanks for replying, Aaron C. I never knew about refactor.
+1  A: 

That class is referenced from the layout file that describes the UI -- http://developer.android.com/resources/samples/NotePad/res/layout/note_editor.html

If you change the name of the Java class without the name the layout file uses, the layout will fail during inflation. You should see in the log an explicit error message about the inflate failing, it being unable to find the LinedEditText class, and what line this happened in.

The NotePad sample doesn't import the LinedEditText class you reference because... well, it is implementing its own LinedEditText right on the code. In fact the source you reference was probably just copied from the NotePad sample.

hackbod
Excellent, thank you hackbod.