我想从main activity访问它,所以我在第二个activity中将时钟设置为public static,在main activity中设置为"secondActivity.chronometer“,但当启动应用程序时,它显示chronometer.setbase(long) on a null object reference,我检查了xml是否正确。
public class MainActivity extends ActionBarActivity { Button start, stop, resetR.layout.activity_main);
start = (Button) findViewById(R.id.button1);
star
然后,我按照我在前面找到的CountDownTimer答案的样式编写了以下代码,用所需的数据更新TextView: final TextView tv = (TextView) findViewById(R.id.tv_show_stopwatch);endMillis); //endMillis is the date in Milliseconds