Cursor location not updated when non-focused EditText clicked
When non-focused EditText clicked, 开发者_StackOverflow社区it becomes focused, but cursor does not move to new location. I should click it again to move cursor to a new position.
Q: How can I focus and move cursor with only one click?
I spent quite some time battling the same problem, and this is what I did:
In your layout xml, enable focusable and focusableInTouchMode
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:focusable="true" android:focusableInTouchMode="true">
</LinearLayout>
Otherwise, whenever the softkeyboard comes up, it automatically scrolls to the front of the EditText. You can modify the position by overriding "OnFocusChangeListener" but it's a little ugly to poll the clicked position every time. I'm going to stick with the change above.
精彩评论