Android – the prompt does not disappear on EditText
•
Android
I have an EditText:
<EditText
android:hint="Your Notes" android:id="@+id/tv_notes_data"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:gravity="right" style="@style/items_description_plain" />
When the user clicks it, I need the prompt to disappear, but this will never happen. Please tell us why
resolvent:
Try using onclicklistener:
editText.setOnClickListener(new OnClickListener {
void onClick(View v) {
editText.setHint("");
// or ((EditText) v).setHint(""));
}
});
To set the prompt again, you can use:
editText.setOnFocuschangelistener(new OnFocuschangelistener {
void OnFocusChange(params) {
editText.setHint("Your Notes");
}
});
By the way, the prompt will disappear only when the user starts typing. In fact, although there are no characters in EditText, the prompt will be displayed
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码