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)

Ammar
  • 1,811
  • 5
  • 26
  • 60

4 Answers4

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

Community
  • 1
  • 1
Blaze Tama
  • 10,828
  • 13
  • 69
  • 129
  • 2
    The issue is that I've multiple `ListView`s in my application and the received crash logs has no info about the one which is causing crash. – Ammar Nov 05 '14 at 11:57
  • @Ammar yes, i know how you feel. I put it on all of my listviews. Unfortunately, i dont know any easier solution. – Blaze Tama Nov 05 '14 at 11:58
  • Tried this but this solution doesn't work. – TomV Oct 11 '22 at 09:50
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);
sudocoder
  • 1,164
  • 1
  • 13
  • 26
Monte Creasor
  • 466
  • 5
  • 12
0

This works for me.

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

Here, parent is the ViewGroup parameter in the getView.

Pang
  • 9,564
  • 146
  • 81
  • 122
sarankumar
  • 229
  • 2
  • 7
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.

truespan
  • 189
  • 1
  • 2
  • 11