屏幕旋转后恢复的TextView的状态呢?屏幕、状态、TextView

2023-09-12 21:40:14 作者:一直都伤心

在我的应用程序我有的TextView EditView中。两人都在它的数据。当屏幕方向改变了数据的 EditView中仍然存在,但的TextView 数据被清除。

In my app I have Textview and EditView. Both have data in it. When the screen orientation changes the data in the Editview remains, but Textview data is cleared.

我很困惑......

I am confused ...

可以有一个人帮助我找到一种方法来保留数据的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

 
精彩推荐
图片推荐