【问题标题】:saving int in onpause在 onpause 中保存 int
【发布时间】:2014-03-17 01:32:26
【问题描述】:
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 被遗漏了?另外,我省略了空间的按钮功能。另外,有这方面的教程吗?

【问题讨论】:

标签: java android onpause


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2012-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-10
    • 1970-01-01
    • 2014-11-20
    • 1970-01-01
    相关资源
    最近更新 更多