Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

This text field does not specify an inputType or a hint

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

like image 430
user2460928 Avatar asked Jun 06 '13 19:06

user2460928


People also ask

What is inputType in android?

The android:inputType attribute allows you to specify various behaviors for the input method. Most importantly, if your text field is intended for basic text input (such as for a text message), you should enable auto spelling correction with the "textAutoCorrect" value.

How to create text field in android studio?

Add a text boxIn the Palette panel, click Text to show the available text controls. Drag the Plain Text into the design editor and drop it near the top of the layout. This is an EditText widget that accepts plain text input.

What is plain text in Android Studio?

Plaintext is nothing but the Edittext. It has changed the name in Android studio but if you check into Design view you will get to know that it still has name of Edittext only. Usages. Textview : should be used for uneditable text which user wants to read but not to manipulate.

What is Imeoption Android studio?

informs the IME that the text field is single line and IME should not show return key. informs the IME whether to automatically capitalize characters, words or sentences. Only applicable to only text based KeyboardType s such as KeyboardType.


1 Answers

The Reason for this warning is that you haven't set the inputType for this editText. Add the following line:

android:inputType="text"

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.

like image 76
mschoenebeck Avatar answered Oct 16 '22 18:10

mschoenebeck