当我点击开始时,'秒表'开始计数..我按下暂停,只有 textview 暂停,它没有恢复,因为它仍在后台运行..我需要它在我停止的地方恢复..
这是我的点 java 代码:
package com.example.chronometer2;
import com.example.chronometer.R;
import android.app.Activity;
import android.os.Bundle;
import android.os.SystemClock;
import android.view.View;
import android.widget.Button;
import android.widget.Chronometer;
public class ChronometerApp extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_chronometer);
final Chronometer myChronometer = (Chronometer)findViewById(R.id.my_chronometer);
Button buttonStart = (Button)findViewById(R.id.buttonstart);
Button buttonStop = (Button)findViewById(R.id.buttonstop);
Button buttonReset = (Button)findViewById(R.id.buttonreset);
buttonStart.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
myChronometer.start();
}});
buttonStop.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
myChronometer.stop();
}});
buttonReset.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
myChronometer.setBase(SystemClock.elapsedRealtime());
}});
}
}