Preventing/catching “IllegalArgumentException: parameter must be a descendant of this view” error

后端 未结 15 1612
北恋
北恋 2020-11-27 13:46

I have a ListView with some focusable components inside (mostly EditTexts). Yeah, I know this isn\'t exactly recommended, but in general, almost everything is w

15条回答
  •  情书的邮戳
    2020-11-27 14:03

    In my case it was related to windowSoftInputMode="adjustPan", listView and editText on list element (header view).

    In order to fix that I call hide soft keyboard method before activity is finished.

    public void hideKeyboard(Activity activity) {
        InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
        View focusView = activity.getCurrentFocus();
        if (focusView != null) {
            inputMethodManager.hideSoftInputFromWindow(focusView.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
        }
    }
    

提交回复
热议问题