IllegalArgumentException parameter must be a descendant of this view at ViewGroup.offsetRectBetweenParentAndChild
Asked Answered
M

4

13

I got following exception from one of my app user in crash logs. Unable to understand from the log trace. If anybody has some thoughts, please share.

Fatal Exception: java.lang.IllegalArgumentException parameter must be a descendant of this view raw

android.view.ViewGroup.offsetRectBetweenParentAndChild (ViewGroup.java:4563) android.view.ViewGroup.offsetDescendantRectToMyCoords (ViewGroup.java:4500) android.view.ViewGroup$ViewLocationHolder.init (ViewGroup.java:6738) android.view.ViewGroup$ViewLocationHolder.obtain (ViewGroup.java:6675) android.view.ViewGroup$ChildListForAccessibility.init (ViewGroup.java:6633) android.view.ViewGroup$ChildListForAccessibility.obtain (ViewGroup.java:6601) android.view.ViewGroup.addChildrenForAccessibility (ViewGroup.java:1703) android.view.ViewGroup.onInitializeAccessibilityNodeInfoInternal (ViewGroup.java:2530) android.view.View.onInitializeAccessibilityNodeInfo (View.java:5209) android.widget.AdapterView.onInitializeAccessibilityNodeInfo (AdapterView.java:937) android.widget.AbsListView.onInitializeAccessibilityNodeInfo (AbsListView.java:1492) android.widget.ListView.onInitializeAccessibilityNodeInfo (ListView.java:3781) android.view.View.createAccessibilityNodeInfoInternal (View.java:5170) android.view.View.createAccessibilityNodeInfo (View.java:5157)

Marilynnmarimba answered 5/11, 2014 at 7:56 Comment(1)
please post the codeEsquire
M
6

I fixed this error by adding a custom listener like this :

protected class MyScrollListener implements OnScrollListener {

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem,
                int visibleItemCount, int totalItemCount) {
            // do nothing 
        }

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
            if (SCROLL_STATE_TOUCH_SCROLL == scrollState) {
                View currentFocus = getCurrentFocus();
                if (currentFocus != null) {
                    currentFocus.clearFocus();
                }
            }
        }

    }

Then use the listener you created :

listview.setOnScrollListener(MyScrollListener);

For more information, see this (code also taken from this link) : Preventing/catching "IllegalArgumentException: parameter must be a descendant of this view" error

Menander answered 5/11, 2014 at 8:2 Comment(3)
The issue is that I've multiple ListViews in my application and the received crash logs has no info about the one which is causing crash.Marilynnmarimba
@Marilynnmarimba yes, i know how you feel. I put it on all of my listviews. Unfortunately, i dont know any easier solution.Menander
Tried this but this solution doesn't work.Elongate
C
4

I tried calling the clearFocus() member of the EditText widget but that did not work for me. What did work, however, was calling the parent's clearChildFocus(View) function. Here it is in code:

ViewParent parent = mEditText.getParent();
parent.clearChildFocus(mEditText);
Caryncaryo answered 17/1, 2015 at 20:23 Comment(1)
worked for me, but worried because i have no idea why it works. can someone explain?Peters
G
0

This works for me.

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

Here, parent is the ViewGroup parameter in the getView.

Giveandtake answered 28/1, 2015 at 7:6 Comment(0)
I
0

I was getting the same error when i tried using edittext with recyclerview. I think the same is applicable for editext with listview usage also.

As the problem happens when there is a focus mismatch while Viewgroup handles the views. For me, what solved the problem was adding android:windowSoftInputMode="adjustPan" to the manifest for the activity concerned.

<activity android:name=".register.RegistrationActivity"
        android:windowSoftInputMode="adjustPan"/>

Hope this is useful to someone.

Incongruity answered 7/11, 2018 at 5:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.