Chang Broot
Lurker
How to start a Chronometer when a DialogFragment is clicked (its OK button)? I have something like the following, but it gives null object reference error. I want the timer to start only after the user clicks the ok button in the dialogFragment.
Java:
public class A extends AppCompatActivity {
private Chronometer mChronometer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity);
mChronometer = findViewById(R.id.chronometer);
mChronometer.setBase(SystemClock.elapsedRealtime());
}
public void startTimer(){
// This method is start using Fragment.
mChronometer.start();
}
}