在forpause中保存int

时间:2014-03-17 01:32:26

标签: java android onpause

public class excuse extends Activity{
    String excuse[] = { "1", "2","3", "4", "5", "6","7","8", "9","10" };
    Button re;
    Button pre;
    TextView dis;
    int counter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.excuse);        
        re = (Button)findViewById(R.id.button1);
        pre = (Button)findViewById(R.id.button2);
        dis = (TextView)findViewById(R.id.textView1);
        counter = 0; 
        counter = counter + 1;
        dis.setText( " hi" + counter );
        counter = counter + 1;
    }
    @Override
    protected void onPause() {
        super.onPause();        
    }
}

如何在某处保存counter,以便在更改活动并返回时知道counter已关闭?另外,我省略了空间按钮功能。此外,这里有任何教程吗?

1 个答案:

答案 0 :(得分:0)

对于"如何在运行之间保存一些数据的更通用的答案",请查看Storage Options Guide。最容易使用的可能是共享首选项。