EditText request focus not working

后端 未结 11 647
自闭症患者
自闭症患者 2020-12-15 17:03

I have an EditText and a Button. On click of the button i want to open the EditText keyboard and at the same time request focus on the

11条回答
  •  旧巷少年郎
    2020-12-15 17:18

    U need two xml attributes also to achieve this:

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

    Add them to the EditText as well as the parent layouts(Any layout inside which these views are). By default these are false, so the focus is not given to the requested view.

    Source: https://developer.android.com/reference/android/view/View.html#attr_android:focusable

    After u show the EditText based on the checkbox selection, add the next and previous focus points dynamically in code.

    Hope this helps.

提交回复
热议问题