另一个java.lang.IllegalArgumentException:参数必须是此视图的后代 [英] Another java.lang.IllegalArgumentException: parameter must be a descendant of this view

查看:103
本文介绍了另一个java.lang.IllegalArgumentException:参数必须是此视图的后代的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用户在某些手机上的我的应用程序中遇到以下异常.我尝试自己重现错误,但无法.我在堆栈溢出中搜索了类似的问题,并尝试了解决方案,但似乎都没有用.

Users are getting the following exception in my app on certain phones. I tried reproducing the error myself but couldn't . I searched through stack overflow for similar problems and tried their solutions but none seem to be working.

以下是我已经尝试过的答案:

Here are the answers I already tried:

  1. 防止/捕获"IllegalArgumentException:参数必须是该视图的后代.错误
  2. java.lang .IllegalArgumentException:参数必须是此视图Error的后代
  3. 设置以下属性:android:windowSoftInputMode="stateHidden|adjustPan"
  1. Preventing/catching "IllegalArgumentException: parameter must be a descendant of this view" error
  2. java.lang.IllegalArgumentException: parameter must be a descendant of this view Error
  3. Setting the following attribute: android:windowSoftInputMode="stateHidden|adjustPan"

我有一个edittext,但它在expandablelistview之外.

I have an edittext but it's outside of the expandablelistview.

我试图找到一种解释,说明为什么会发生这种情况以及可能导致这种情况发生的原因.抱歉,我无法发布任何代码.

I am trying to find an explanation on why this is happening and what might cause it to happen. I apologize but I can't post any code.

java.lang.IllegalArgumentException:参数必须是的后代 这个观点 在android.view.ViewGroup.offsetRectBetweenParentAndChild(ViewGroup.java:4568) 在android.view.ViewGroup.offsetDescendantRectToMyCoords(ViewGroup.java:4505) 在android.view.ViewGroup $ ViewLocationHolder.init(ViewGroup.java:6743) 在android.view.ViewGroup $ ViewLocationHolder.obtain(ViewGroup.java:6680) 在android.view.ViewGroup $ ChildListForAccessibility.init(ViewGroup.java:6638) 在android.view.ViewGroup $ ChildListForAccessibility.obtain(ViewGroup.java:6606) 在android.view.ViewGroup.addChildrenForAccessibility(ViewGroup.java:1697) 在android.view.ViewGroup.onInitializeAccessibilityNodeInfoInternal(ViewGroup.java:2525) 在android.view.View.onInitializeAccessibilityNodeInfo(View.java:5213) 在android.widget.AdapterView.onInitializeAccessibilityNodeInfo(AdapterView.java:946) 在android.widget.AbsListView.onInitializeAccessibilityNodeInfo(AbsListView.java:1449) 在android.widget.ListView.onInitializeAccessibilityNodeInfo(ListView.java:3781) 在android.widget.ExpandableListView.onInitializeAccessibilityNodeInfo(ExpandableListView.java:1348) 在android.view.View.createAccessibilityNodeInfoInternal(View.java:5174) 在android.view.View.createAccessibilityNodeInfo(View.java:5161) 在android.view.AccessibilityInteractionController $ AccessibilityNodePrefetcher.prefetchDescendantsOfRealNode(AccessibilityInteractionController.java:811) 在android.view.AccessibilityInteractionController $ AccessibilityNodePrefetcher.prefetchDescendantsOfRealNode(AccessibilityInteractionController.java:834) 在android.view.AccessibilityInteractionController $ AccessibilityNodePrefetcher.prefetchDescendantsOfRealNode(AccessibilityInteractionController.java:834) 在android.view.AccessibilityInteractionController $ AccessibilityNodePrefetcher.prefetchAccessibilityNodeInfos(AccessibilityInteractionController.java:720) 在android.view.AccessibilityInteractionController.findAccessibilityNodeInfoByAccessibilityIdUiThread(AccessibilityInteractionController.java:147) 在android.view.AccessibilityInteractionController.access $ 300(AccessibilityInteractionController.java:49) 在android.view.AccessibilityInteractionController $ PrivateHandler.handleMessage(AccessibilityInteractionController.java:971) 在android.os.Handler.dispatchMessage(Handler.java:102) 在android.os.Looper.loop(Looper.java:136) 在android.app.ActivityThread.main(ActivityThread.java:5097) 在java.lang.reflect.Method.invokeNative(Method.java) 在java.lang.reflect.Method.invoke(Method.java:515) 在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:785) 在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) 在dalvik.system.NativeStart.main(NativeStart.java)

java.lang.IllegalArgumentException: parameter must be a descendant of this view at android.view.ViewGroup.offsetRectBetweenParentAndChild(ViewGroup.java:4568) at android.view.ViewGroup.offsetDescendantRectToMyCoords(ViewGroup.java:4505) at android.view.ViewGroup$ViewLocationHolder.init(ViewGroup.java:6743) at android.view.ViewGroup$ViewLocationHolder.obtain(ViewGroup.java:6680) at android.view.ViewGroup$ChildListForAccessibility.init(ViewGroup.java:6638) at android.view.ViewGroup$ChildListForAccessibility.obtain(ViewGroup.java:6606) at android.view.ViewGroup.addChildrenForAccessibility(ViewGroup.java:1697) at android.view.ViewGroup.onInitializeAccessibilityNodeInfoInternal(ViewGroup.java:2525) at android.view.View.onInitializeAccessibilityNodeInfo(View.java:5213) at android.widget.AdapterView.onInitializeAccessibilityNodeInfo(AdapterView.java:946) at android.widget.AbsListView.onInitializeAccessibilityNodeInfo(AbsListView.java:1449) at android.widget.ListView.onInitializeAccessibilityNodeInfo(ListView.java:3781) at android.widget.ExpandableListView.onInitializeAccessibilityNodeInfo(ExpandableListView.java:1348) at android.view.View.createAccessibilityNodeInfoInternal(View.java:5174) at android.view.View.createAccessibilityNodeInfo(View.java:5161) at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchDescendantsOfRealNode(AccessibilityInteractionController.java:811) at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchDescendantsOfRealNode(AccessibilityInteractionController.java:834) at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchDescendantsOfRealNode(AccessibilityInteractionController.java:834) at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchAccessibilityNodeInfos(AccessibilityInteractionController.java:720) at android.view.AccessibilityInteractionController.findAccessibilityNodeInfoByAccessibilityIdUiThread(AccessibilityInteractionController.java:147) at android.view.AccessibilityInteractionController.access$300(AccessibilityInteractionController.java:49) at android.view.AccessibilityInteractionController$PrivateHandler.handleMessage(AccessibilityInteractionController.java:971) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5097) at java.lang.reflect.Method.invokeNative(Method.java) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) at dalvik.system.NativeStart.main(NativeStart.java)

推荐答案

问题是由于向两个不同的列表视图添加了错误夸大的标头而引起的.

The problem was caused by adding a wrongly inflated header to two different listviews.

我使用listViewA作为父视图来放大视图,并将其也添加到listViewB中.因此:

I inflated a view using listViewA as the parent and adding it to listViewB also. As such:

RelativeLayout listViewHeader = (RelativeLayout) inflater.inflate(R.layout.listviewheader, listViewA, false);

// Set some views

listViewA.addHeaderView(listViewHeader);
listViewB.addHeaderView(listViewHeader);

我通过将以上内容更改为以下内容来修复它:

I fixed it 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);

对于重现崩溃,打开Goog​​le Talk Back时发生了问题.这是我的情况:Google Talk Back在焦点对准的视图(通过触摸或自动聚焦)上进行文本到语音的对话.当进入具有多个请求焦点的视图的屏幕时,它将根据层次结构/顺序读取视图.

As for reproducing the crash, the problem happened when Google Talk Back is turned on. Here is my take on the situation: Google Talk Back does text to speech on views that are in focus (either by touch or auto-focused). When it enters a screen with multiple views requesting focus, it reads the views according to a hierarchy/order.

如果您的版式(父级)具有三个视图(子级),则Google Talk Back会检查视图的排列方式,然后相应地读取它们.例如,在具有三个水平排列的textview的布局中,Google Talk Back可能会先读取左侧的textview,然后读取中间的textview,然后读取右侧的textview.

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 textview lined up horizontally, Google Talk Back may read the left textview first, then the middle one, then the one on the right.

在我的情况下,我将以listViewA作为父级的标头视图放大,并将该视图添加到listViewAlistViewB中.当listViewB获得焦点并且Google Talk Back尝试解释其子级时,它会看到标题视图不是列表的子级,并引发异常.如果我在没有父项的情况下向标头视图充气(空),也会发生这种情况.

In my case, I was inflating a header view with listViewA as the parent and adding that view to both listViewA and listViewB. When listViewBgains focus and Google Talk Back tries to interpret its children, it sees the header view is not a child of the list and throws the exception. This also happens if I inflate the header view with no parents (null).

这篇关于另一个java.lang.IllegalArgumentException:参数必须是此视图的后代的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆