Reputation: 5273
I have a SeekBar
with a TextView
shown above the thumb when it's moving (as a tooltip). Also, there's an EditText
below the seekbar:
When I'm not moving the seekbar's thumb, the TextView
isn't shown. It appears only when I move the thumb or change the number in the EditText
. I want it to disappear when I stop moving the thumb, or after I finish typing in the EditText
.
I got it to disappear on stop-tracking but problem is it sticks there if I type something in the EditText
.
I tried:
@Override
public void afterTextChanged(Editable arg0) {
textView.setVisibility(GONE);
}
but this doesn't seem to work. When I type something it appears, and it sticks there, until I move the thumb.
How can I get it to disappear after I finish typing?
Upvotes: 1
Views: 811
Reputation: 407
You can try this:
editText.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable str) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
textView.setVisibility(View.GONE);
}
}, 500);
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
textView.setVisibility(View.VISIBLE);
}
});
You can also add handler for post delay of 500 ms which will give more proper view.
Upvotes: 1
Reputation: 333
Try it, It looks like you are missing View.
@Override
public void afterTextChanged(Editable arg0) {
textView.setVisibility(View.GONE);
}
Upvotes: 1