How to stop EditText from gaining focus at Activity startup in Android

后端 未结 30 2767
别那么骄傲
别那么骄傲 2020-11-21 06:40

I have an Activity in Android, with two elements:

  1. EditText
  2. ListView

When my Activity

30条回答
  •  -上瘾入骨i
    2020-11-21 07:30

    Excellent answers from Luc and Mark however a good code sample is missing. Adding the tag android:focusableInTouchMode="true" and android:focusable="true" to parent layout (e.g. LinearLayout or ConstraintLayout) like the following example will fix the problem.

    
    
    
    
    
    

提交回复
热议问题