Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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)

like image 891
Ammar Avatar asked Nov 05 '14 07:11

Ammar


1 Answers

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

like image 97
Blaze Tama Avatar answered Sep 18 '22 14:09

Blaze Tama