I have an activity with a scrollview containing some buttons and a EditText So the buttons are above the EditText component.
By clicking on a Button the EditText component change his text value by using EditText.setText("foo");
Unfortunately this call will set the focus to the EditText component, so the ScrollView will scroll to the EditText component (cursor blinks).
Is there a way to avoid this?
I have tried to do something like this
public void setText(String t){
editText.setFocusable(false)
editText.setFocusableInTouchMode(false);
editText.setText(t);
editText.setFocusable(true);
editText.setFocusableInTouchMode(true);
}
But that does not work, and sometimes setFocusable(true)
has no impact, so the EditText is not "clickable" anymore.
editText.clearFocus();
Called when this view wants to give up focus.
http://developer.android.com/reference/android/view/View.html#clearFocus()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With