我正在使用此wheel picker,并试图找到暂时禁用用户交互的方法。到目前为止,我尝试了以下内容:
wheelPicker.setEnabled(false);
wheelPicker.setFocusable(false);
wheelPicker.setOnClickListener(null);
wheelPicker.setClickable(false);
答案 0 :(得分:1)
试试这个:
wheelPicker.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
答案 1 :(得分:0)
最终我只是将WheelPicker类扩展为启用了一个方法。
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import com.aigestudio.wheelpicker.WheelPicker;
public class MyWheelPicker extends WheelPicker {
boolean enabled = false;
public MyWheelPicker(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean onTouchEvent(MotionEvent event){
if(enabled == true){
super.onTouchEvent(event);
}
return true;
}
@Override
public void setEnabled(boolean enabled){
this.enabled = enabled;
}
}