屏幕旋转后恢复TextView的状态? [英] Restoring state of TextView after screen rotation?
问题描述
在我的应用程序中,我有 TextView
和 EditText
.两者都有数据.当屏幕方向改变时,EditText
中的数据保留,但 TextView
数据被清除.
In my app I have TextView
and EditText
. Both have data in it. When the screen orientation changes the data in the EditText
remains, but TextView
data is cleared.
有人可以帮我找到一种方法来保留 TextView
中的数据吗?
Can some one help me out to find a way to retain data in TextView
too?
推荐答案
如果你想强制你的 TextView
保存它的状态,你必须添加 freezesText
属性:
If you want to force your TextView
to save its state you must add freezesText
attribute:
<TextView
...
android:freezesText="true" />
来自 freezesText
:
如果设置,除了元数据(例如当前光标位置)之外,文本视图将在其冻结的冰柱内包含其当前的完整文本.默认情况下这是禁用的;当文本视图的内容未存储在持久性位置(例如内容提供者)中时,它会很有用
If set, the text view will include its current complete text inside of its frozen icicle in addition to meta-data such as the current cursor position. By default this is disabled; it can be useful when the contents of a text view is not stored in a persistent place such as a content provider
这篇关于屏幕旋转后恢复TextView的状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!