Another parameter is java.lang.IllegalArgumentException: the parameter must be a descendant of this view

Users get the following exception in my application on some phones. I myself tried to reproduce the error, but could not. I looked for a stack overflow for similar problems and tried to solve them, but none of them work.

Here are the answers I've tried:

I have an edittext, but it is outside the extensible list.

I am trying to find an explanation of why this is happening and what could lead to it. Sorry, but I can not post the code.

java.lang.IllegalArgumentException: the parameter must be a descendant of this view in android.view.ViewGroup.offsetRectBetweenParentAndChild (ViewGroup.java:4568) on android.view.ViewGroup.offsetDescendantRectToMyCoords (ViewGroup.java:4505) in android.view.Viewolroup $ .init (ViewGroup.java:6743) in android.view.ViewGroup $ ViewLocationHolder.obtain (ViewGroup.java:6680) in android.view.ViewGroup $ ChildListForAccessibility.init (ViewGroup.java:6638) in android.view.ViewGroup $ ChildListForAccessibility.obtain (ViewGroup.java:6606) at android.view.ViewGroup.addChildrenForAccessibility (ViewGroup.java:1697) in android.view.ViewGroup.onInitializeAccessibilityNodeInfoInternal (ViewGroup.java:2525) in android.view.View.onInitialial .java: 5213) at android.widget.AdapterView.onInitializeAccessibilityNodeInfo (AdapterView.java:946) at android.widget.AbsListView .onInitializeAccessibilityNodeInfo (AbsListView.java:1449) in android.widget.ListView.onInitializeAccessibilityNodeInfo (ListView.javahaps781) in android.widget.ExpandableListView.onInitializeAccessibilityNodeInfo (ExpandableListView.java13.13ave.4813.aalate.4813.aava13.13w.a1313.a13a1313a.a13a13a13a13 ... java: 5174) in android.view.View.createAccessibilityNodeInfo (View.javaโˆ—161) at android.view.AccessibilityInteractionController $ AccessibilityNodePrefetcher.prefetchDescendantsOfRealNode (AccessibilityInteractionController.java:811) at android.view.Alerp : 834) at android.view.AccessibilityInteractionController $ AccessibilityNodePrefetcher.prefetchAccessibility NodeInfos (AccessibilityInteractionController.java:720) at android.view.AccessibilityInteractionController.findAccessibilityNodeInfoByAccessibilityIdUiThread (AccessibilityInteractionController.java:147) at android.view.AccessibilityInteraction. control AccessibilityInteractionController.java:971) on android.os.Handler.dispatchMessage (Handler.java:102) on android.os.Looper.loop (Looper.java:136) in android.app.ActivityThread.main (ActivityThread.java:5097 ) in java.lang.reflect.Method.invokeNative (Method.java) in java.lang.reflect.Method.invoke (Method.javaโˆ—15) at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit. java: 785) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:601) in dalvik.system.NativeStart.main (NativeStart.java)

+6
source share
3 answers

The problem was caused by adding an incorrectly bloated header to two different lists.

I inflated the view using listViewA as a parent and adding it to listViewB . In this way:

 RelativeLayout listViewHeader = (RelativeLayout) inflater.inflate(R.layout.listviewheader, listViewA, false); // Set some views listViewA.addHeaderView(listViewHeader); listViewB.addHeaderView(listViewHeader); 

I fixed this by changing the above to the following:

 RelativeLayout listViewHeaderA = (RelativeLayout) inflater.inflate(R.layout.listviewheader, listViewA, false); RelativeLayout listViewHeaderB = (RelativeLayout) inflater.inflate(R.layout.listviewheader, listViewB, false); listViewA.addHeaderView(listViewHeaderA); listViewB.addHeaderView(listViewHeaderB); 

As for crash playback, the problem occurs when Google Talk Back is turned on. Here's my view of the situation: Google Talk Back makes text-to-speech from views that are in focus (either by touch or autofocus). When he enters a screen with several views, asking for focus, he reads the views in accordance with the hierarchy / order.

If you have a layout (parent) with three views (children), Google Talk Back checks how the views are arranged and then reads them accordingly. For example, in a layout with three textures aligned horizontally, Google Talk Back may first read the left text view, then the middle, and then the right.

In my case, I inflated the header with listViewA as the parent and added this view to both listViewA and listViewB . When listViewB gets focus and Google Talk Back tries to interpret its children, it sees that the title is not a child of the list and throws an exception. This also happens if I inflate the header without parents (null).

+5
source

I also get the same error when Google TalkBack is enabled. In my case, I was inflating the view with the boolean trueToParent true. Therefore, making it false, I worked for me.

0
source

I have an application to listen to scroll in ScrollView and solve the problem

  lst_payment_info.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { if (SCROLL_STATE_TOUCH_SCROLL == scrollState) { View currentFocus = getCurrentFocus(); if (currentFocus != null) { currentFocus.clearFocus(); } } } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { } }); 
0
source

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


All Articles