什么是TextView中的(s/g)etFreezesText? [英] What is (s/g)etFreezesText in TextView?

查看:77
本文介绍了什么是TextView中的(s/g)etFreezesText?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近(可能是一项新的SDK功能),当我尝试从 Textview 中提取文本时,我首先获得了方法 getFreezesText(),而不是 getText().

As of recently (probably as a new SDK feature), when I try to pull text from a Textview, I first get the method getFreezesText(), instead of getText().

我看了看这个方法的定义,上面写着

I looked at the definition of this method and it says

**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)

这对我无济于事.

什么时候应该使用这些方法(如果有的话)?它们是新的还是我刚刚注意到它们?

When we are supposed to use these methods (if ever at all)? Are they new or I've just noticed them?

推荐答案

如果您要强制您的 TextView (或 EditText 等)保存其状态,您必须添加 freezesText 属性:

If you want to force your TextView (or EditText etc. for that matter) 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

该属性和方法自API 1起就存在,因此我会说您刚刚注意到它.

The attribute and method have existed since API 1, so I'll say you just noticed it.

这篇关于什么是TextView中的(s/g)etFreezesText?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆