Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is (s/g)etFreezesText in TextView?

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)

This tells nothing to me.

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

like image 956
sandalone Avatar asked Jan 05 '13 17:01

sandalone


1 Answers

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" />

From documentation on 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

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

like image 126
Raghav Sood Avatar answered Oct 07 '22 18:10

Raghav Sood