如何在使用后退按钮关闭我的活动时如何保存,并且恢复时的方式与关闭时的方式相同。我该如何保存我的活动状态
这是我的活动代码:
公共类级别扩展活动{
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setTheme(android.R.style.Theme_NoTitleBar_Fullscreen);
setContentView(R.layout.levels);
final EditText anstext1 = (EditText) findViewById(R.id.anstext1);
Button button1 = (Button) findViewById(R.id.button1);
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String result = anstext1.getText().toString();
if(result.equals("they"))
setContentView(R.layout.social);
else
Toast.makeText(getApplicationContext(), "Wrong", Toast.LENGTH_LONG).show();
}
});
}
}
搜索帮助... http://stackoverflow.com/questions/151777/saving-activity-state-in-android(一式两份) – ElefantPhace 2013-04-05 03:30:56
“恢复”应用程序关闭后指并重新启动? – 2013-04-05 03:39:46