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

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

I have an Activity in Android, with two elements:

  1. EditText
  2. ListView

When my Activity

30条回答
  •  花落未央
    2020-11-21 07:17

    Yeah I did the same thing - create a 'dummy' linear layout which gets initial focus. Furthermore, I set the 'next' focus IDs so the user can't focus it any more after scrolling once:

    
    
    
    dummy.setNextFocusDownId(et.getId());
    
    dummy.setNextFocusUpId(et.getId());
    
    et.setNextFocusUpId(et.getId());
    

    a lot of work just to get rid of focus on a view..

    Thanks

提交回复
热议问题