EditText hint error in Android

I am trying to set hint to be question mark (?). If I set it as string in xml file I get error

Error: Resource id cannot be an empty string (at 'hint' with value '?').

<EditText
        android:id="@+id/txt_to_edit"
        android:layout_width="92dp"
        android:layout_height="wrap_content"
        android:layout_column="8"
        android:layout_gravity="bottom"
        android:layout_row="5"
        android:layout_rowSpan="6"
        android:hint="?"
        android:text="@string/txt_label"/>

If I set the hint to point at @string/quest in strings.xml I get the same error. If I try to use ! or anything similir it works fine. I am using Android SDK 4. Thanks

<EditText
            android:id="@+id/txt_to_edit"
            android:layout_width="92dp"
            android:layout_height="wrap_content"
            android:layout_column="8"
            android:layout_gravity="bottom"
            android:layout_row="5"
            android:layout_rowSpan="6"
            android:hint="@string/quest"
            android:text="@string/txt_label"/>

Upvotes: 4

Views: 4108

Answers (2)

David West
David West

Reputation: 2328

I agree with Amokrane.

Maybe try

<EditText
    android:id="@+id/txt_to_edit"
    android:layout_width="92dp"
    android:layout_height="wrap_content"
    android:layout_column="8"
    android:layout_gravity="bottom"
    android:layout_row="5"
    android:layout_rowSpan="6"
    android:hint="\?"
    android:text="@string/txt_label"/>

Upvotes: 1

Amokrane Chentir
Amokrane Chentir

Reputation: 30405

? is considered as a special character (used for ?android:attr for example). Try with \?.

Upvotes: 9

Related Questions