Here is the problem with double hint - TextInputLayout and EditText double hint issue
I need to do the same. I need two hints. One is a title of EditText, and second is a possible value if nothing wasn't input.
But unfortunately there is only one tag:
android:hint
Can I do something with it?
UPD1:
The answer was to set hint for EditText programatically and hint for TextInputLayout in xml.
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:hint="@string/prompt_quantity"
android:layout_height="wrap_content">
<EditText
android:id="@+id/quantity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number"
android:maxLines="1"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
And
quantityEditText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
quantityEditText.setHint(hasFocus ? "0" : "");
}
});
Just check your input and change the hint depending on that:
EditText editText = (EditText)findViewById(R.id.editText);
editText.addTextChangedListener(new TextWatcher()
{
@Override
public void afterTextChanged(Editable s)
{
if(editText.getText().toString().equals(""))
editText.setHint("");
else
editText.setHint("Your normal hint");
}
});