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

后端 未结 15 1611
北恋
北恋 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:07

    Based on @Bruce answer, can resolve error with recyclerview like this:

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    
            View currentFocus = ((Activity)context).getCurrentFocus();
            if (currentFocus != null) {
                currentFocus.clearFocus();
            }
    }
    

提交回复
热议问题