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

I have a weird bug with ViewGroup. For my main view, I use classes in these 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 occurs when I try to return to this view using Intent or finish (); method in a different view. When I use the back button, this is not a problem.

So I don’t know why I have this error. Thank you for your help.

+2
source share
3 answers

Have the same problem. I use ViewFlow as a parent view and several GridViews as children. This error occurs when I press the Home key and restart the action again after scrolling these child views left and right.

Here is my solution:

 mViewFlow.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); 

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

Hope this can help you.

+2
source

This works for me.

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

Here parent is the ViewGroup parameter in getView.

0
source

Solved the problem of adding a scroll listener.

 @Override public View getView(int position, View convertView, ViewGroup parent) { View currentFocus = ((Activity)mContext).getCurrentFocus(); if (currentFocus != null) { currentFocus.clearFocus(); } } 
0
source

Source: https://habr.com/ru/post/988363/


All Articles