java.lang.IllegalArgumentException: parameter must be a descendant of this view Error

前端 未结 4 1313
暖寄归人
暖寄归人 2021-01-21 04:21

I have a strange Error with a ViewGroup. For my main View I use classes in this links ViewFlow project

    java.lang.IllegalArgumentException: parameter must be          


        
相关标签:
4条回答
  • 2021-01-21 04:56

    I had the same issue when deleting item from recycler view which contains EditText. Just before notifying adapter that item was deleted I used

    (requireContext() as Activity).currentFocus?.clearFocus()
    
    0 讨论(0)
  • 2021-01-21 05:02

    Solved my problem with adding scroll listener.

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
    
        View currentFocus = ((Activity)mContext).getCurrentFocus();
        if (currentFocus != null) {
            currentFocus.clearFocus();
        }  
    }
    
    0 讨论(0)
  • 2021-01-21 05:17

    This works for me.

    convertView = mInflater.inflate(R.layout.row_stat_header,
                        parent, false);  
    

    Here, parent is the ViewGroup parameter in the getView.

    0 讨论(0)
  • 2021-01-21 05:19

    Have the same problem. I use a ViewFlow as the parent view and several GridView as child views.This error happens when I press the Home key and restart the activity again after I scrolled these child views left and right.

    Here is my solution:

    mViewFlow.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
    

    Of course, you can config it in layout.xml.

    Hope that can help you.

    0 讨论(0)
提交回复
热议问题