From 8948d47067dc12a7f7258b4bc0e8628916e53531 Mon Sep 17 00:00:00 2001 From: nnrohu Date: Sat, 3 Oct 2020 14:57:26 +0530 Subject: [PATCH] Update EditTextWithClear.java hide clear button when edittext is empty --- .../example/android/customedittext/EditTextWithClear.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CustomEditText/app/src/main/java/com/example/android/customedittext/EditTextWithClear.java b/CustomEditText/app/src/main/java/com/example/android/customedittext/EditTextWithClear.java index 92b3af7..3f60a1a 100644 --- a/CustomEditText/app/src/main/java/com/example/android/customedittext/EditTextWithClear.java +++ b/CustomEditText/app/src/main/java/com/example/android/customedittext/EditTextWithClear.java @@ -129,7 +129,10 @@ public void beforeTextChanged(CharSequence s, @Override public void onTextChanged(CharSequence s, int start, int before, int count) { - showClearButton(); + if (count > 0) + showClearButton(); + else + hideClearButton(); } @Override