Custom EditText is not showing keyboard on focus

馋奶兔 提交于 2019-12-03 01:34:33

It's an old question but if someone cares, the problem is on the implementation of the constructor:

public CustomFontEditText(Context context, AttributeSet attrs) {
    this(context, attrs, 0);
    this.context = context;
}

The last argument ("defStyle") which you set as 0, should be the default style for an EditText. If you take a look at the same constructor on the EditText class:

public EditText(Context context, AttributeSet attrs) {
    this(context, attrs, com.android.internal.R.attr.editTextStyle);
}

As you can see, the default style for an EditText should be used, so your constructor should look like this:

public CustomFontEditText(Context context, AttributeSet attrs) {
    this(context, attrs, android.R.attr.editTextStyle);
    this.context = context;
}

add this

 android:focusable="true"
implements KeyListener on your custom EditText Class and override methods of KeyListener

try to make reference for edit text at runtime and call request focus()

    et.requestFocus()

and try

   android:focusable="true"
 editText.setOnTouchListener(new OnTouchListener() 
  {
    @Override
    public boolean onTouch(View v, MotionEvent event) 
     {
         editText.setFocusableInTouchMode(true);
         return false;
     }
  });
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!