android - 当我将文本输入布局添加到我的 xml 文件时,它的工作但当我单击日期选择器类应用程序崩溃时
问题描述
我正在将我的编辑文本制作为材料设计(使用 TextInputLayout)。它工作正常。但是当我点击我的 DatePicker 时,应用程序崩溃说:
Attempt to invoke virtual method 'int android.widget.NumberPicker.getChildCount()' on a null object reference
我的gradle文件如下
apply plugin: 'com.android.application'
我不明白,删除 TextInputLayout 解决了问题......
注意:我已Theme.AppCompat.Light
在清单中定义
解决方案
Attempt to invoke virtual method 'int android.widget.NumberPicker.getChildCount()' on a null object reference
From this, you can see that the exception is a NullPointerException. and it says that, getChildCount() method was called on a null point. Which means that, the object of type NumberPicker
is null.
So, if you've initialized the object, please check the initialization part of your code. And your findViewById might be also not working as well if the ID wasn't found in the XML file.
推荐阅读
- php - .htaccess 更改后本地 symfony 5 无法正常工作
- deep-learning - DenseNet,张量的大小必须匹配
- android - 无法解析配置“:classpath”的所有工件。(在 android studio 中构建问题)
- typescript - 为什么`SomeObject[SomeEnum]`的类型从来不在这里
- flutter - Flutter:在等待 Google 登录完成时显示加载小部件
- r - 下载 WorldPop 人口计数栅格
- css - CSS 表格 - 用细线分隔行
- android - 单击“现在不”或“取消”后,应用内审核提示不可见
- c++ - 如何在 C++ 代码中捕获未处理的异常
- excel - 如何在 VBA 中为动态范围应用自动填充功能?