EditText in PopupWindow not showing keyboard even if setFocusable(true)

前端 未结 5 926
小鲜肉
小鲜肉 2020-12-17 10:28

I can\'t seem to get this work. I already set popWindow focusable as to what I read on other forums but still no luck.

xml



        
相关标签:
5条回答
  • 2020-12-17 10:41

    ha, .found the answer., just did

    popWindow.setFocusable(true);
    popWindow.update();
    

    thanks for the support! credits from this topic Keyboard not shown when i click on edittextview in android?

    0 讨论(0)
  • 2020-12-17 10:44

    Try adding this line before you show the popup:

    popupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    
    0 讨论(0)
  • 2020-12-17 10:47

    Try this::

    Programatically:

    edittext.requestFocus();
    

    Through xml:

    <EditText
    android:id="@+id/editText3"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10"
    android:inputType="textPersonName">
        <requestFocus />
    </EditText>
    

    Hope it Helps!!

    0 讨论(0)
  • 2020-12-17 10:50

    This worked for me:

    popWindow.setFocusable(true);
    popWindow.update();
    
    0 讨论(0)
  • 2020-12-17 10:54

    Nothing helped me, it still didn't appear on some devices, so I had to force showing it like that (kotlin):

    val editText = customView.findViewById<EditText>(numberFieldId)
            editText.onClick {
                showKeyboard(editText, context)
            }
    
    private fun showKeyboard(mEtSearch: EditText, context: Context) {
            mEtSearch.requestFocus()
            val imm = context.getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager
            imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0)
        }
    
    0 讨论(0)
提交回复
热议问题