14

最近(おそらく新しい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)

これは私には何も教えてくれません。

これらの方法を使用することになっているのはいつですか(あるとしても)?それらは新しいですか、それとも私はそれらに気づきましたか?

4

2 に答える 2

13

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

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

上のドキュメントからfreezesText

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

属性とメソッドはAPI1から存在しているので、気付いたと思います。

于 2013-01-05T18:16:53.787 に答える
1

android:freezesText="true"最後に完成したテキストをフリーズします。しかし、最後に完成したテキストは何ですか? 2秒ごとに変化するを表示しているtextViewとすると、画面を回転させるまではすべて問題ありません。画面を回転させると、textView内のテキストは表示されなくなります。ここでfreezesText、最後に表示されたテキスト(最後に完成したテキスト)がフリーズします。 。

于 2020-09-05T06:19:04.490 に答える