MultiLineRadioGroup icon indicating copy to clipboard operation
MultiLineRadioGroup copied to clipboard

PerformClick(); issue

Open dev-hussein opened this issue 8 years ago • 4 comments

Hello ,, I Think this peace of code

public void checkAt(int index) {
    if(index >= 0 && index < this.mRadioButtons.size()) {
        this.checkButton((RadioButton)this.mRadioButtons.get(index));
    }
}

private void checkButton(RadioButton button) {
    if(button != null) {
        if(button != this.mCheckedButton) {
            if(this.mCheckedButton != null) {
                this.mCheckedButton.setChecked(false);
            }

            button.setChecked(true);
            this.mCheckedButton = button;
        }

    }
}

not called "mOnCheckedChangeListener" i think after define 'mCheckedButton' just call 'button.performClick();' this will call the listener. to be like that -->

public void checkAt(int index) {
    if(index >= 0 && index < this.mRadioButtons.size()) {
        this.checkButton((RadioButton)this.mRadioButtons.get(index));
    }
}

private void checkButton(RadioButton button) {
    if(button != null) {
        if(button != this.mCheckedButton) {
            if(this.mCheckedButton != null) {
                this.mCheckedButton.setChecked(false);
            }

            button.setChecked(true);
            this.mCheckedButton = button;
            button.performClick();
        }

    }
}

i hope updating this peace of code. Thanks ,,,, @Gavras

dev-hussein avatar Dec 11 '17 10:12 dev-hussein

Sorry i think the better updating code is -->

public void checkAt(int index) {
    if(index >= 0 && index < this.mRadioButtons.size()) {
        RadioButton button = (RadioButton)this.mRadioButtons.get(index);
        if (button != null) button.performClick();
    }
}

this will handle checkButton method; @Gavras

dev-hussein avatar Dec 11 '17 10:12 dev-hussein

Sorry I'm not sure I followed your question.

OnClickListener is an interface which tells the activity about click events in the view. The activity has no other way to detect those clicks because it doesn't manage the radio buttons, the view does. checkAt() is not a click event. It is called by the activity. The activity has a way to detect these checks, well it is the one who's calling them.

What functionality exactly are you missing or can't perform in the current release of this library?

Gavras avatar Dec 11 '17 12:12 Gavras

i have checker code when radio button checked , i add your listener "setOnCheckedChangeListener" and do what i do on it; But when i call checkAt() method my checker code not working because your listener not called;

so i think you should get button from index and then perform click on it this will call checkButton() method and listener. @Gavras

dev-hussein avatar Dec 11 '17 15:12 dev-hussein

Like I said - onClick() is for click events. OnCheckedChangeListener is for state change.

I updated the library and added a release (here) to address the issue when methods check() and checkAt() didn't call OnCheckedChangeListener.

Please try it and comment here if it fix your issue.

Gavras avatar Dec 11 '17 18:12 Gavras