我想从 2 个 edittexts( et1,et2
) 中保存文本并从 3 个微调器(微调器、微调器和微调器 2)onPause 中进行选择并将它们重新设置为 onResume。来自 edittexts 的文本已正确保存,只有微调器选择无法按预期工作。我的代码:
public void onResume(){
super.onResume();
Log.d("REZUM","notr smo");
SharedPreferences seti = getSharedPreferences( "pavzica", MODE_PRIVATE);
spinnerm.setSelection(seti.getInt("m", 0));
spinner.setSelection(seti.getInt("k", 0));
spinner2.setSelection(seti.getInt("p", 0));
et1.setText(seti.getString("zade", ""));
et2.setText(seti.getString("Vseb", ""));
}
public void onPause() {
shraniPolja();
super.onPause();
}
public void shraniPolja() {
SharedPreferences seti = getSharedPreferences( "pavzica", MODE_PRIVATE);
SharedPreferences.Editor edito = seti.edit();
edito.putString("zade", et1.getText().toString());
edito.putString("Vseb", et2.getText().toString());
edito.putInt("m", spinnerm.getSelectedItemPosition());
edito.putInt("k", spinner.getSelectedItemPosition());
edito.putInt("p", spinner2.getSelectedItemPosition());
edito.putBoolean("b", true);
edito.commit();
}
我究竟做错了什么?