我正在使用一个名为MBWheelPicker开源选择器的Wheel选择器,该类扩展了View,并具有几个接口OnScrollChangeListener和OnItemSelectedListener。当用户暂停应用程序并在向轮式选择器输入输入时返回时,onchangelistener在选择器视图的OnDraw方法中为null,并抛出被零除的异常。
这是构造函数的代码段:
public MBWheelPicker(Context){
this(context, null)
}
public MBWheelPicker(Context context, AttributeSet attrs){
super(context, attrs)
//here initialize TypedArray other Styleable stuff in the xml
}
那时我的应用程序崩溃了。我无法包含该类的全部代码,因为它包含数百行代码。我该怎么解决?
两个侦听器都是嵌套在WheelPicker类本身中的接口。
答案 0 :(得分:0)
作为自定义视图,它应该覆盖OnDetachWindow和onAttachWindow侦听器;就我而言,它没有后者。我添加了它,现在它的侦听器不为null,并且它引起的讨厌的dividbyzero异常消失了。