mercredi 4 février 2015

Save CheckBox state in app

I have checkbox in my android app. My checkbox is checked when app's first run. What if user disable checkbox? I don't want to save preferences in my app.


Every time isChecked is true for my arrangement. After user change checkbox How can I save the state of the checkbox?


xml:



<CheckBox
android:id="@+id/remember_me"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#FF297AA6"
android:checked="true"
android:textColor="@android:color/white" />


Here my activity code - Always isChecked true from my xml;



if (mCheckBox.isChecked()) {
remembername = preferences.getString("user", "");
rememberpassword = preferences.getString("pasword", "");
user.setText(remembername);
parola.setText(rememberpassword);
}




Aucun commentaire:

Enregistrer un commentaire