2013-01-05 25 views
8

Textviewからテキストを取り込もうとすると、最近(おそらく新しいSDKの機能として)、の代わりにgetFreezesText()というメソッドが取得されます。TextViewの(s/g)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) 

これは私に何も伝えていないと言います。

これらのメソッドを使用する予定がある場合(これはまったくありません)彼らは新しいのですか、それとも気づいたのですか? freezesText

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

ドキュメントから:

答えて

8

あなたはその状態を保存するために(そのことについてまたはEditTextなど)あなたのTextViewを強制したい場合は、freezesText属性を追加する必要があります

設定した場合テキストビューには、現在のカーソル位置などのメタデータに加えて、固定されたicicleの中に現在の完全なテキストが含まれます。デフォルトでは、これは無効になっています。テキストビューのコンテンツがコンテンツプロバイダなどの永続的な場所に格納されていない場合に役立ちます。

属性とメソッドはAPI 1以降存在していたので、気づいたと思います。

+0

出力はどのように表示されますか?表示されるテキストのみです(テキストの長さがTextViewの幅より大きい場合)? – sandalone

+0

ドキュメントには「現在の完全なテキスト」と書かれています。私は個人的にそれを使用していない。 –

関連する問題