EditText request focus not working

后端 未结 11 666
自闭症患者
自闭症患者 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:21

    The above solutions will work if the EditText is enabled.

    In my code, I have disabled the view at one point and trying to request focus later without enabling. If none of the above worked, enable the EditText and then proceed with the above solutions.

    In my case it is like,

     etpalletId.isEnabled = true
     etpalletId.text!!.clear()
     etpalletId.requestFocus()
     etpalletId.isCursorVisible = true
    

提交回复
热议问题