2013-01-05 42 views
8

最近(可能作爲一個新的SDK功能),當我嘗試從Textview拉文本時,我首先得到方法getFreezesText(),而不是getText()什麼是(s/g)在TextView中的etFreezesText?

我看着這個方法的定義,它說

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

這告訴我什麼都不是。

當我們應該使用這些方法(如果有的話)?他們是新的還是我剛剛注意到他們?

回答

8

如果要強制TextView(或EditText等爲此事),以保存其狀態必須添加freezesText屬性:

<TextView 
    ... 
    android:freezesText="true" /> 

從文檔上freezesText

如果集除了當前光標位置等元數據之外,文本視圖還將在凍結冰柱內包含當前的完整文本。默認情況下,這是禁用的;當文本視圖的內容不被存儲在持久性的地方,如內容提供商

的屬性和方法,因爲API 1已存在它可能是有用的,所以我會說你只是注意到了這一點。

+0

輸出結果如何?它只是可見的文本(如果文本長度大於TextView寬度)? – sandalone

+0

該文檔說明了「當前的完整文本」。我個人雖然沒有使用它。 –

相關問題