开发者

The cursor is moving to the left of entered text instead of right on Honeycomb

This is a kind of strange problem. One of the EditText controls we are using is moving the cursor to the left of typed text instead of the right. This only happens on Honeycomb (same code on Gingerbread works fine) and it only happens in this particular EditText control and only the first time you start typing. Any ideas?

<EditText android:id="@+id/preview_range_edit"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
    android:digits=",-0123456789"
    android:maxLines="1" 
    android:singleLine="true"
    android:layout_toRightOf="@id/preview_range_txt"
    android:layout_toLeftOf="@id/preview_range_radio"
    android:layout_centerVertical="true"/>

Edited to add that after some additional testing I found this is only a problem if the device is in por开发者_C百科trait orientation, not in landscape.


So I found the answer, had nothing to do with my layout. Part of the processing of the data of my EditText control was calling a notifyDataSetChange that was taking the focus away from my EditText control and then returning it but on return it was resetting the cursor incorrectly. This is probably a bug in the OS. The workaround for me was to add an OnFocusChangeListener to my EditText control and store the cursor when focus was lost and restore the cursor when focus was returned.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜