简体   繁体   中英

How can set Hint Text in code?

I have:

<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>

And I need add Hint Text , If I added hint text in xml, in EditText:

android:hint="@string/s_amount"

all nice, but if I add etAmount.setHint(R.string.s_amount); in code - String (hint text) does not popup ((, Why?

请将提示设置为TextInputLayout。

mTextInputLayout.setHint("your hint here");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM