Android Layout make all children's not clickable

后端 未结 12 2165
一生所求
一生所求 2021-01-01 12:45

I am using Relative Layout and many buttons in it with TextViews etc.I want to make all of them not clickable unless some event happens.

12条回答
  •  情歌与酒
    2021-01-01 13:03

    Problem : same as original question, but different use case. i want to progressBar widget which in container with transparent background colors. i want to disable all clicks on other items which comes under my transparent background color .

    solution : just set your container clickable in my case Relative layout, it can any other layout too, keep your layout clickable true, until you want according to condition in my case till api call completed. after it simply set your parent clickable false.

    android xml

    
    
    
    ...
    
    
    
    
    

    Java:

    rl_parent.setClickable(true); // when to disable all clicks of children view
    
    rl_parent.setClickable(false); // when to enable all clicks of children view
    

提交回复
热议问题