▶ Persistent State
실행화면
소스 위치 : src/com/example/android/apis/app/PersistentState.java
첫번째 EditText 창의 글자는 App이 종료되더라도 계속 같은 값을 유지하게 된다.
DialogActivity Class와 매치되는 XML은 save_restore_state.xml
setContentView(R.layout.save_restore_state);
▦ save_restore_state.xml 파일 내용
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:padding="4dip"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<TextView android:id="@+id/msg"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_weight="0"
android:paddingBottom="4dip" />
<TextView
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_weight="0"
android:paddingBottom="4dip"
android:text="@string/saves_state"/>
<EditText android:id="@+id/saved"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/green"
android:text="@string/initial_text"
android:freezesText="true">
<requestFocus />
</EditText>
<TextView
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_weight="0"
android:paddingTop="8dip"
android:paddingBottom="4dip"
android:text="@string/no_saves_state"/>
<EditText
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/red"
android:text="@string/initial_text">
</EditText>
</LinearLayout>>
android:layout_width="fill_parent" android:layout_height="fill_parent">
<TextView android:id="@+id/msg"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_weight="0"
android:paddingBottom="4dip" />
<TextView
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_weight="0"
android:paddingBottom="4dip"
android:text="@string/saves_state"/>
<EditText android:id="@+id/saved"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/green"
android:text="@string/initial_text"
android:freezesText="true">
<requestFocus />
</EditText>
<TextView
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_weight="0"
android:paddingTop="8dip"
android:paddingBottom="4dip"
android:text="@string/no_saves_state"/>
<EditText
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/red"
android:text="@string/initial_text">
</EditText>
</LinearLayout>>
android:freezesText 속성
: Freezeon 상태가 될때 Text의 내용을 저장하는지 여부, 기본으로 false값으로 저장하지 않는다.
true로 설정되게 되면 불변의 저장소(persistent storage : content provider 처럼)에 저장하게 되며, App을 종료한 뒤에도 다시 실행했을때 그 값을 계속 유지하게 된다.
: Freezeon 상태가 될때 Text의 내용을 저장하는지 여부, 기본으로 false값으로 저장하지 않는다.
true로 설정되게 되면 불변의 저장소(persistent storage : content provider 처럼)에 저장하게 되며, App을 종료한 뒤에도 다시 실행했을때 그 값을 계속 유지하게 된다.
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
".
'Android > ApiDemos' 카테고리의 다른 글
[미완] App - Activity - Receive Result (0) | 2010.03.18 |
---|---|
App - Activity - QuickContactsDemo (2) | 2010.03.17 |
App - Activity - Persistent State (0) | 2010.03.17 |
App - Activity - Hello World (0) | 2010.03.17 |
App - Activity - Forwarding (0) | 2010.03.17 |
App - Activity - Dialog (0) | 2010.03.17 |