问题描述
我遇到了 EditText 控件的问题.这个问题只发生在这个特定的活动上,没有其他带有 EditTexts 的活动.我已删除此 EditText 的所有 setText 调用,但问题仍然存在.
I'm having an issue with an EditText control. This issue is only happening on this particular Activity and no other Activities with EditTexts. I have removed all setText calls for this EditText and the problem still persists.
我在移动设备上运行 Android 2.3.4.它是 Nexus S 和运行库存的 Android.在模拟器中(运行 Android 2.2)不会出现这个问题.
I am running Android 2.3.4 on my mobile device. It is a Nexus S and running stock Android. In the emulator (running Android 2.2) this problem does not occur.
当我旋转手机时,Android 会自动替换旋转前 EditText 中的文本.我没有使用 savedInstanceState 做任何事情.Android 本身就是这样做的.
When I rotate the phone, Android automatically replaces the text that was in the EditText before the rotation. I'm not using savedInstanceState to do anything. Android is doing this itself.
我的问题:
假设test"一词在 EditText 中.当我旋转手机时,Android 会在重新创建 Activity 时将testtest"放入 EditText.这仅在我使用虚拟键盘键入 EditText 时发生,我没有单击虚拟键盘上的完成"按钮,我按下返回以移除虚拟键盘,然后旋转设备.如果我使用完成"按钮而不是返回按钮,则不会出现问题.
Suppose the word "test" is in the EditText. When I rotate the phone, Android will place "testtest" into the EditText when the Activity is re-created. This only happens when I use the virtual keyboard to type into the EditText, I do not click the "done" button on the virtual keyboard, I press back to remove the virtual keyboard, and I then rotate the device. If I use the "done" button instead of the back button, the problem does not occur.
有什么想法吗?正如我所说,我不设置文本.所有调用 setText 的行都被注释掉了.
Any ideas? As I said, I am NOT setting the text. All lines that call setText have been commented out.
更新 1:我已经注释掉了这个 Activity 中的所有内容,除了 onCreate() 方法.问题仍然存在.
更新 2:我创建了一个新 Activity.这个全新的 Activity 只有一个 onCreate() 方法.onCreate() 方法中唯一的事情是调用 setContentView(使用相同的布局文件)并调用 super 的 onCreate().问题仍然存在.我难住了.我唯一能猜到的是布局文件有些古怪.我不知道那会是什么.
更新 3:除了 EditText 之外,我已经从布局中删除了所有内容.问题仍然存在.
推荐答案
我也遇到过类似的问题,但只有在 EditText 的 AutoComplete 开启时才能看到.
I had a similar problem but I only see it when the AutoComplete is turned on for the EditText.
我的解决方法是禁用自动完成功能.
My work around was to disable autocomplete.
<EditText
.
.
.
android:inputType="textMultiLine|textNoSuggestions"
/>
这篇关于EditText 在旋转时翻倍的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

![[ios.cocos2d+box2d]如何禁用自动旋转? [ios.cocos2d+box2d]如何禁用自动旋转?](/assets/images/default.png)
大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)