我在片段中使用 CountDownTimer 有时 onFinish() 会抛出错误
附加错误消息和错误代码
public void onFinish()
{
btnTimerStart.setText(getString(R.string.btn_restart));
timer_display.setTextSize(45);
timer_display.setText(getString(R.string.btn_complete));
}
java.lang.IllegalStateException:
at android.support.v4.app.Fragment.requireContext (Fragment.java:696)
at android.support.v4.app.Fragment.getResources (Fragment.java:760)
at android.support.v4.app.Fragment.getString (Fragment.java:782)
at com.sinwho.timer.TimerFragment$11.onFinish (TimerFragment.java:751)
at android.os.CountDownTimer$1.handleMessage (CountDownTimer.java:127)
at android.os.Handler.dispatchMessage (Handler.java:106)
at android.os.Looper.loop (Looper.java:214)
at android.app.ActivityThread.main (ActivityThread.java:7050)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:965)