我制作了一个从 100000 开始倒计时的计数器应用程序。每次我将设备旋转 90° 或停止它时,它都会再次从 100000 开始。如何让我的应用停止自行重置?
代码:
public class SecondActivity extends Activity {
int counter = 1000001;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
}
public void onClick(View v){}
public void button1 (View v){
counter--;
final Button button2 = (Button) findViewById(R.id.button2);
button2.setText("" + counter);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.second, menu);
return true;
}
}