Android CheckBox remains state after destroy -


i have simple application single checkbox. thought when android destroy activity state of checkbox list. happens is, checkbox keeps checked.

the ondestroy() called (on rotation or when switch app -> emulator has dev configuration).

so why work without using onrestoreinstancestate() , onsaveinstancestate()?

android target 4.2 jelly bean.

here activity:

public class coffeemixeractivity extends activity {  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_coffee_mixer); }  protected void ondestroy() {     super.ondestroy();      log.d("mymessage", "destroy app"); } } 

here layout file:

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" tools:context=".coffeemixeractivity" >  <checkbox     android:id="@+id/checkboxsprinkles"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:text="sprinkles" />  </relativelayout> 

ok.. found solution myself: android checkbox -- restoring state after screen rotation

description: every view have android:saveenabled flag on true.. means when view have id state automatically saved when view freezed...

here there attribute documentation: http://developer.android.com/reference/android/r.attr.html#saveenabled


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -