如何在用户点击android中的禁用复选框时显示祝酒词

时间:2016-06-19 15:26:52

标签: android user-interface checkbox

我不希望点击事件更改checkbox的状态。相反,我想显示toast。所以我使用checkbox.setEnabled(false),但如果我这样做,我就无法显示toast。我现在没有任何想法

2 个答案:

答案 0 :(得分:2)

我说做你想做的事情是不好的用户体验。

例如,人们应该可以看到您的复选框已从其颜色中禁用。他们不希望能够与之互动。

答案 1 :(得分:0)

使用OnTouchListener对于整个活动,然后检测操作是向下触摸并检查坐标以使其符合复选框位置

this.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
    if(event.getAction() == MotionEvent.ACTION_DOWN){

        //check e.getX() and e.getY() so that it is inside the checkbox area
        return true; //only if the touch is on the check box 
        //return false otherwise
    }
    return false;
}
});
相关问题