RadioGroup.setEnabled(false) doesn't work as expected

前端 未结 3 391
你的背包
你的背包 2021-02-05 01:46

I have used setEnabled(false) to set it unable, but it doesn\'t work and after this method, the value of RadioGroup.isEnabled() is false. The value was

相关标签:
3条回答
  • 2021-02-05 02:16

    use the following method:

    for (int i = 0; i < testRadioGroup.getChildCount(); i++) {
        testRadioGroup.getChildAt(i).setEnabled(false);
    }
    
    0 讨论(0)
  • 2021-02-05 02:19

    You can't use the following code;

    for(View lol : your_spinner.getTouchables() ) {
        lol.setEnabled(false);
    }
    

    Once the views has disabled, there is no touchable child/descentant views anymore.

    0 讨论(0)
  • 2021-02-05 02:23

    Views can be compose by multiple touchable elements. You have to disable them all, like this:

    for(View lol : your_spinner.getTouchables() ) {
        lol.setEnabled(false);
    }
    

    If it is a simple one since it also returns itself:

    Find and return all touchable views that are descendants of this view, possibly including this view if it is touchable itself.

    View#getTouchables()

    0 讨论(0)
提交回复
热议问题