Android Activity中获取当前焦点的控件,自动化输入EditText

获取焦点的view对象
  View view=getWindow().getDecorView().findFocus(); 
如果是EditText
  if(view instanceof EditText)   {    ((EditText) view).setText("当前焦点");   }

来自网站:http://www.echojb.com/android/2016/12/31/292167.html

自己布局:RelativeLayout:rl_root包裹ScrollView,里面包裹多个EditText;使用rl_root.getFocused();只能获取到ScrollView对象

相关文章:

  • 2022-12-23
  • 2021-11-04
  • 2021-08-23
  • 2022-12-23
  • 2021-06-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-08
  • 2021-06-02
  • 2021-05-20
  • 2022-12-23
  • 2022-12-23
  • 2021-07-20
  • 2021-12-19
相关资源
相似解决方案