Skip to content

Issue with checkbox and onTouchEvent #23

@ToLive

Description

@ToLive

My app have list of Cards with custom layout. One of the views is your Checkbox. And I have a strange issue: if I press the Checkbox and remove finger only after move it off the Checkbox, then the circle background around the Checkbox stays on. This doesn't happen if I remove the finger on the Checkbox. I think it may interfere with List onTouchEvent. For me, I fix this by modify your CheckBox.java in this part:

@Override
public boolean onTouchEvent(MotionEvent event)
{
    isLastTouch = true;
    if (event.getAction() == MotionEvent.ACTION_DOWN)
    {
        changeBackgroundColor((check) ? makePressColor() : Color.parseColor("#446D6D6D"));
    } else if ((event.getAction() == MotionEvent.ACTION_UP)
            | (event.getAction() == MotionEvent.ACTION_CANCEL))
    {
        changeBackgroundColor(getResources().getColor(android.R.color.transparent));
        press = false;
        if ((event.getX() <= getWidth() && event.getX() >= 0)
                && (event.getY() <= getHeight() && event.getY() >= 0))
        {
            isLastTouch = false;
            check = !check;
            if (onCheckListener != null)
                onCheckListener.onCheck(check);
            if (check)
            {
                step = 0;
            }
            if (check)
                checkView.changeBackground();
        }
    }
    return true;
}

So I've just modify this part:

else if ((event.getAction() == MotionEvent.ACTION_UP)
            | (event.getAction() == MotionEvent.ACTION_CANCEL))

Thank you for your library and sorry for my English :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions