How to find out which view is focused?

前端 未结 6 548
后悔当初
后悔当初 2020-12-01 17:32

I need to find out if any view is focused inside an Activity and what view it is. How to do this?

6条回答
  •  醉酒成梦
    2020-12-01 18:30

    for some reason getCurrentFocus() method isn't available anymore; probably it's deprecated already, here the working alternative:

    View focusedView = (View) yourParentView.getFocusedChild();
    

提交回复
热议问题