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

Substitut picture Substitut · May 23, 2012 · Viewed 10.9k times · Source

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 a descendant of this view
        at android.view.ViewGroup.offsetRectBetweenParentAndChild(ViewGroup.java:4153)
        at android.view.ViewGroup.offsetDescendantRectToMyCoords(ViewGroup.java:4090)
at android.view.ViewRootImpl.scrollToRectOrFocus(ViewRootImpl.java:2129)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:1849)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1641)
at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2449)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)

This error happens when I try to go back to this view with an Intent or a finish(); method in an other View. When I use the Back Button it's not a problem.

So i don't know why I have this Error. Thanks for your Help.

Answer

Nodin picture Nodin · Mar 25, 2014

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.