Can I change the text of a floating tooltip EditText?

Is it possible to change the text of a floating tooltip depending on whether the text is floating or is inside an EditText ?

For example, when the field is empty, I would like to see the text "Your name", and when the tooltip is floating, I would like to see the text "Name".

Here's what it looks like now:

 <android.support.design.widget.TextInputLayout android:layout_width="match_parent" android:layout_height="wrap_content" > <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Your name" android:textColorHint="@color/dark_grey" android:textColor="@color/dark_grey" android:background="@drawable/edittext_bg" > <requestFocus/> </EditText> </android.support.design.widget.TextInputLayout> 
+4
source share
2 answers

This will be done using TextInputLayout and EditText onFocusChangeListener.

 textInputLayoutEmail.setHint("Enter your Email id"); editText.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { textInputLayoutEmail.setHint("Email"); } }); 

Remove tooltip from EditText in an XML file,

 <android.support.design.widget.TextInputLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:textColorHint="@color/dark_grey" android:textColor="@color/dark_grey" android:background="@drawable/edittext_bg"> <requestFocus /> </EditText> </android.support.design.widget.TextInputLayout> 
+3
source
 EditText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { EditText.setHint("Name"); } }); 
0
source

All Articles