Custom EditText is not showing keyboard on focus

后端 未结 6 1032
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-01 04:21

I am creating a custom EditText class because i need to set some custom fonts; However now when i click on the editText the android keyboard does not pop up anymore...

h

6条回答
  •  灰色年华
    2021-02-01 04:47

    Make custom EditText with Kotlin to fix focus problem:

    class MyEditText @JvmOverloads constructor(
    context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = android.R.attr.editTextStyle) : AppCompatEditText(context, attrs, defStyleAttr) {
    
    
     init {
        doSomething(context)
     }
    
     private fun doSomething(context: Context) {
       // TODO Set your custom font or whatever you need
     }
    
    }
    

提交回复
热议问题