最近在做一个应用,其中一个界面上有几个EditText,我发现每次启动这个界面之后焦点就自动落在第1个EditText上,从而使EditText的提示不能显示。

解决的方法是:

     在EditText的父组件(比如linearlayout)添加两个属性:

        android:focusable="true" 
        android:focusableInTouchMode="true"      

   如果没有父组件的话可以添加一个隐藏的 linearLayout,并加上上面的两个属性

<LinearLayout
        android:focusable="true" 
        android:focusableInTouchMode="true"
        android:layout_width="0px" 
        android:layout_height="0px"
/>

  


相关文章:

  • 2021-07-04
  • 2022-12-23
  • 2021-11-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-30
  • 2022-01-08
  • 2021-11-12
  • 2022-01-25
  • 2022-02-10
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案