gpt4 book ai didi

android - IllegalArgumentException 参数必须是此 View 在 ViewGroup.offsetRectBetweenParentAndChild 处的后代

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:06:57 24 4
gpt4 key购买 nike

我的一位应用程序用户在崩溃日志中收到以下异常。无法从日志跟踪中理解。如果有人有任何想法,请分享。

致命异常:java.lang.IllegalArgumentException参数必须是此 View 的后代 生的

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)

最佳答案

我通过添加这样的自定义监听器修复了此错误:

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();
}
}
}

}

然后使用您创建的监听器:

listview.setOnScrollListener(MyScrollListener);

有关更多信息,请参阅此(代码也取自此链接):Preventing/catching "IllegalArgumentException: parameter must be a descendant of this view" error

关于android - IllegalArgumentException 参数必须是此 View 在 ViewGroup.offsetRectBetweenParentAndChild 处的后代,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26752161/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com