2016-05-12 12 views
1

ich habe:Wie kann Hint Text im Code gesetzt werden?

<android.support.design.widget.TextInputLayout 
        android:id="@+id/ti_amount_layout" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center_horizontal" 
        android:layout_marginTop="10dp" 
        android:layout_marginBottom="10dp" 
        android:theme="@style/BlueAccentColor"> 

        <EditText 
         android:id="@+id/et_amount" 
         style="@style/EditTextRedBorder" 
         android:layout_width="@dimen/product_selector_width" 
         android:background="@drawable/contacts_bg_mess" 
         android:textColorHint="@color/palette_contacts_send_mess_text" 
         android:textColor="@color/palette_black" 
         android:inputType="numberDecimal"> 

        </EditText> 

       </android.support.design.widget.TextInputLayout> 

Und ich brauche Hinweis Text, fügen Wenn ich Hinweistext in XML hinzugefügt, in EditText:

android:hint="@string/s_amount" 

alle nett, aber wenn ich hinzufügen etAmount.setHint(R.string.s_amount); in Code - String (Hinweistext) nicht popup ((Warum?

+0

Wo verwenden Sie die SetHint-Funktion in Ihrem Code? Kannst du es uns zeigen? – Xema

+0

Verwenden Sie 'etAmount.setHint (getResources(). GetString (R.string.s_amount));' Sie versuchen, ihm die Ressourcen-ID zu übergeben, anstatt den Wert zu erhalten, den die Ressourcen-ID identifiziert. – zgc7009

Antwort

3

den Hinweis auf die TextInputLayout stattdessen ein.

mTextInputLayout.setHint("your hint here");