只有当我尝试强制布局显示带有递增和递减按钮的选择器时才会出现问题.因此,当我在我的片段中使用此代码并按“”或“ – ”时,应用程序崩溃:
final Context contextthemeWrapper = new ContextthemeWrapper(getActivity(), R.style.cust_dialog); LayoutInflater localinflater = inflater.cloneInContext(contextthemeWrapper);
如果我评论上面的代码行,一切正常.
这是cust_dialog:
<style name="cust_dialog" parent="@androID:style/theme.NoTitlebar.Fullscreen"></style>
这是堆栈跟踪:
09-06 01:15:35.947: E/AndroIDRuntime(19858): FATAL EXCEPTION: main09-06 01:15:35.947: E/AndroIDRuntime(19858): java.lang.NullPointerException09-06 01:15:35.947: E/AndroIDRuntime(19858): at androID.Widget.TimePicker.updateinputState(TimePicker.java:580)09-06 01:15:35.947: E/AndroIDRuntime(19858): at androID.Widget.TimePicker.access<TimePicker androID:ID="@+ID/timePicker" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_gravity="center_horizontal"> <requestFocus /> </TimePicker>
0(TimePicker.java:56)09-06 01:15:35.947: E/AndroIDRuntime(19858): at androID.Widget.TimePicker.onValueChange(TimePicker.java:150)09-06 01:15:35.947: E/AndroIDRuntime(19858): at androID.Widget.NumberPicker.notifyChange(NumberPicker.java:1776)09-06 01:15:35.947: E/AndroIDRuntime(19858): at androID.Widget.NumberPicker.setValueInternal(NumberPicker.java:1562)09-06 01:15:35.947: E/AndroIDRuntime(19858): at androID.Widget.NumberPicker.changeValueByOne(NumberPicker.java:1592)09-06 01:15:35.947: E/AndroIDRuntime(19858): at androID.Widget.NumberPicker.access0(NumberPicker.java:90)09-06 01:15:35.947: E/AndroIDRuntime(19858): at androID.Widget.NumberPicker.onClick(NumberPicker.java:633)09-06 01:15:35.947: E/AndroIDRuntime(19858): at androID.vIEw.VIEw.performClick(VIEw.java:4202)09-06 01:15:35.947: E/AndroIDRuntime(19858): at androID.vIEw.VIEw$PerformClick.run(VIEw.java:17340)09-06 01:15:35.947: E/AndroIDRuntime(19858): at androID.os.Handler.handleCallback(Handler.java:725)09-06 01:15:35.947: E/AndroIDRuntime(19858): at androID.os.Handler.dispatchMessage(Handler.java:92)09-06 01:15:35.947: E/AndroIDRuntime(19858): at androID.os.Looper.loop(Looper.java:137)09-06 01:15:35.947: E/AndroIDRuntime(19858): at androID.app.ActivityThread.main(ActivityThread.java:5039)09-06 01:15:35.947: E/AndroIDRuntime(19858): at java.lang.reflect.Method.invokeNative(Native Method)09-06 01:15:35.947: E/AndroIDRuntime(19858): at java.lang.reflect.Method.invoke(Method.java:511)09-06 01:15:35.947: E/AndroIDRuntime(19858): at com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)09-06 01:15:35.947: E/AndroIDRuntime(19858): at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:560)09-06 01:15:35.947: E/AndroIDRuntime(19858): at dalvik.system.NativeStart.main(Native Method)
我该如何解决这个问题?
解决方法:
在timepicker中添加标签.这个对我有用:
参考:http://blog.csdn.net/ljb_blog/article/details/9153435
总结以上是内存溢出为你收集整理的android – 按下按钮加号或减号时的TimePicker空指针异常全部内容,希望文章能够帮你解决android – 按下按钮加号或减号时的TimePicker空指针异常所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)