我正在对材料设计(使用textInputlayout)进行诚意。
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
您的 NumberPicker
是null,它不是初始化的,或者如果您使用了 findViewById
,则尚未找到它,因此,在null对象上调用 getChildCount
会抛出nullpoInterExcept。
尝试解析NumberPicker
参考并确保其不是null并在您的视图/活动/片段中找到的。
尝试调用虚拟方法'int android.widget.numberpicker.getChildCount()'在空对象上 参考
从中,您可以看到异常是NullPoInterException。它说,getChildCount()方法在空点上被调用。这意味着,NumberPicker
类型的对象为null。
因此,如果您已经初始化了对象,请检查代码的初始化部分。如果在XML文件中找不到ID,则您的FindViewByID也可能无法正常工作。