質問

I've got a number picker in my activity. It's possible for the user to do a text selection on the current number. The problem is I'd like to reset the selection when the orientation change to avoid the change of the action bar. As extreme solution I could disable selection but I don't know how. I tried to call clearFocus, I tried to set empty longClikListner, I tried to set setSelected(false) and so on. How can I reset a text selection?

役に立ちましたか?

解決 2

I post the solution after a lot of work :) Use a dummy layout element with focus, clear the focus from the number picker and request the focus from your dummy element, but you have to do this in onResume and onPause.

他のヒント

Supposing the field is an EditText:

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    text.setSelection(0, 0);
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top