从最近开始(可能是SDK的一项新功能),当我尝试从Textview
中提取文本时,我首先获得了getFreezesText()
方法,而不是getText()
。
我看着这个方法的定义,它说
**android: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.
Must be a boolean value, either "true" or "false".
This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.
This corresponds to the global attribute resource symbol freezesText.
Related Methods
setFreezesText(boolean)
这对我没有任何意义。
我们什么时候应该使用这些方法(如果有的话)?它们是新的还是我刚刚注意到它们?
最佳答案
如果要强制TextView
(或EditText
等)保存其状态,则必须添加 freezesText
属性:
<TextView
...
android:freezesText="true" />
从
freezesText
的文档中:该属性和方法自API 1起就存在,因此我会说您刚刚注意到它。