Method to get all EditTexts in a View

后端 未结 5 682
无人共我
无人共我 2020-11-30 07:58

can anyone help me with coding a method to get all EditTexts in a view? I would like to implement the solution htafoya posted here: How to hide soft keyboard on android afte

5条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-30 08:04

    This Methods walks recursively through all ViewGroups and collects their TextViews. I use this to assign a new Color to all TextViews (even those embedded in predefined Widgets like Switch etc that make use of TextViews)

    private HashSet getTextViews(ViewGroup root){
        HashSet views=new HashSet<>();
        for(int i=0;i

提交回复
热议问题