I get the warning, “This text field does not specify an inputType or a hint” When I modify a copy of a tutorial code (below)
<EditText android:id="@+id/edit_message" android:layout_width="wrap_content" android:layout_height="wrap_content" android:hint="@string/edit_message" android:layout_weight="1" />
This works fine, and the warning only comes up if a new blank line is created
I’ve modified it for a friend with several comments lines explaining what each part of it does however, whenever i add in an extra line in the above (Even a blank line, in this case it’s a comment line) I receive the above error
<!--edit text creates a text input box--> <EditText android:id="@+id/edit_message" <!-- edit_message is a variable, defined in strings.xml--> <!-- determines the width of the textField, in this case 0dp means "however long the text is" IE: it will grow to fit however many characters the user types --> android:layout_width="0dp" <!-- determines the height of the Text Field --> android:layout_height="wrap_content" <!-- The hint is the default value for the text field, it calls on the variable edit_message defined in strings.xml--> android:hint="@string/edit_message" <!-- Weight means how much the screen the text field can take up, in this case, the ratio is 1:1 so it can take up however much room is needed, However if a different variable also had the weight of 1, the ratio would be 1:2 and each could take up half the screen --> android:layout_weight="1" />
Without the comments, the warning is not there
The Reason for this warning is that you haven’t set the inputType for this editText. Add the following line:
So it should look like this:
<EditText android:id="@+id/edit_message" android:inputType="text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:hint="@string/edit_message" android:layout_weight="1" />
And the warning is gone.
Logically you should get warning in the line
and an error in the next line.
When you are placing comment tags, then the closing tag of comment is considered as the illegal closing tag for
EditText. So you should even get the following error
Element type "EditText" must be followed by either attribute specifications, ">" or "/>".
and because of the above error the remaining code is not executed and thus you get a warning
This text field does not specify an inputType or a hint
android:hint attribute exists in your code.
I just run your code and got my app running properly, when i added the comment it crashes, then i realized that you should not comment inside your XML , it is a principle of XML.
I suggest you to read this article explaning what is a well formed XML and how to comment xml in the right way http://webdesign.about.com/cs/xmlinformation/ht/htcommentxml.htm
Also here has been a discussion about this particularly subject and has been solved as well.
Hope it helps you.