Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
654 views
in Technique[技术] by (71.8m points)

android - Force Close on Changing time: Time Picker (NPE)

When I click on the time picker for changing the time I get force close.

Can anybody tell me where is the problem in my code. Android. and this is my code......

timePickerDateTimePickerPopup = (TimePicker) layoutDateTimePickerPopup.findViewById(R.id.timePicker_datetimepicker);
            timePickerDateTimePickerPopup.setDescendantFocusability(TimePicker.FOCUS_BLOCK_DESCENDANTS);
            timePickerDateTimePickerPopup.setIs24HourView(true);
            timePickerDateTimePickerPopup.setCurrentHour(mCalendar.get(Calendar.HOUR_OF_DAY));
            timePickerDateTimePickerPopup.setCurrentMinute(mCalendar.get(Calendar.MINUTE));

            timePickerDateTimePickerPopup.setOnTimeChangedListener(this);

            dateTimePickerPopup.setTouchable(true);
            dateTimePickerPopup.setFocusable(true);
            dateTimePickerPopup.setOutsideTouchable(true);
            Drawable image_saved = context.getResources().getDrawable(R.drawable.dummy_bg);
            dateTimePickerPopup.setBackgroundDrawable(image_saved);

My Logcat shows a NullPointerException:

STACK_TRACE=java.lang.NullPointerException
at android.widget.TimePicker.updateInputState(TimePicker.java:553)
at android.widget.TimePicker.access$000(TimePicker.java:55)
at android.widget.TimePicker$2.onValueChange(TimePicker.java:149)
at android.widget.NumberPicker.notifyChange(NumberPicker.java:1777)
at android.widget.NumberPicker.changeCurrent(NumberPicker.java:1455)
at android.widget.NumberPicker.changeCurrentByOne(NumberPicker.java:1481)
at android.widget.NumberPicker.access$100(NumberPicker.java:70)
at android.widget.NumberPicker$2.onClick(NumberPicker.java:592)
at android.view.View.performClick(View.java:3519)
at android.view.View$PerformClick.run(View.java:14140)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
at dalvik.system.NativeStart.main(Native Method)
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This is a known native android bug. See bug #24387 in Android Bug Tracker.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...