{"record":{"id":"6107968322f1926e","repo":"Tencent/QMUI_Android","slug":"action-view-already-exists-other-parent-view","errorCode":null,"errorMessage":"Action view already exists other parent view.","messagePattern":"Action view already exists other parent view\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"qmui/src/main/java/com/qmuiteam/qmui/widget/pullLayout/QMUIPullLayout.java","lineNumber":237,"sourceCode":"\n    public void setActionView(View view, LayoutParams lp) {\n        PullActionBuilder builder = new PullActionBuilder(view, lp.edge)\n                .canOverPull(lp.canOverPull)\n                .pullRate(lp.pullRate)\n                .needReceiveFlingFromTargetView(lp.needReceiveFlingFromTarget)\n                .receivedFlingFraction(lp.receivedFlingFraction)\n                .scrollSpeedPerPixel(lp.scrollSpeedPerPixel)\n                .targetTriggerOffset(lp.targetTriggerOffset)\n                .triggerUntilScrollToTriggerOffset(lp.triggerUntilScrollToTriggerOffset)\n                .scrollToTriggerOffsetAfterTouchUp(lp.scrollToTriggerOffsetAfterTouchUp)\n                .actionInitOffset(lp.actionInitOffset);\n        view.setLayoutParams(lp);\n        setActionView(builder);\n    }\n\n    public void setActionView(@NonNull PullActionBuilder builder) {\n        if (builder.mActionView.getParent() != this) {\n            throw new RuntimeException(\"Action view already exists other parent view.\");\n        }\n        if (builder.mActionView.getParent() == null) {\n            ViewGroup.LayoutParams lp = builder.mActionView.getLayoutParams();\n            if (lp == null) {\n                lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);\n            }\n            addView(builder.mActionView, lp);\n        }\n        if (builder.mPullEdge == PULL_EDGE_LEFT) {\n            mLeftPullAction = builder.build();\n        } else if (builder.mPullEdge == PULL_EDGE_TOP) {\n            mTopPullAction = builder.build();\n        } else if (builder.mPullEdge == PULL_EDGE_RIGHT) {\n            mRightPullAction = builder.build();\n        } else if (builder.mPullEdge == PULL_EDGE_BOTTOM) {\n            mBottomPullAction = builder.build();\n        }\n    }","sourceCodeStart":219,"sourceCodeEnd":255,"githubUrl":"https://github.com/Tencent/QMUI_Android/blob/026e7d486677d6593a96689cd590ec3561176717/qmui/src/main/java/com/qmuiteam/qmui/widget/pullLayout/QMUIPullLayout.java#L219-L255","documentation":"QMUIPullLayout.setActionView(PullActionBuilder) throws when the builder's action view is already attached to a different parent. Like setTargetView, the layout only accepts detached views or its own children as action views.","triggerScenarios":"Calling pullLayout.setActionView(builder) where builder.mActionView still has a non-null parent other than this pull layout — e.g. a view inflated and attached elsewhere, or reused from another pull layout/edge.","commonSituations":"Reusing the same action view (or builder) for multiple pull layouts or multiple edges; creating the action view and attaching it to a temporary container before passing it in.","solutions":["Detach the action view from its current parent (parent.removeView(view)) before setActionView.","Create a new action view / builder instance per pull layout or per edge.","If it must be attached to this layout already, only reuse views that are direct children of this QMUIPullLayout."],"exampleFix":"// before\npullLayout.setActionView(sameBuilder); // action view used by another layout\n// after\nPullActionBuilder builder = new PullActionBuilder(actionView);\npullLayout.setActionView(builder); // freshly created, unattached action view","handlingStrategy":"type-guard","validationCode":"Object parent = builder.mActionView.getParent();\nif (parent == null || parent == pullLayout) {\n    pullLayout.setActionView(builder);\n}","typeGuard":"private static boolean canSetAction(QMUIPullLayout layout, PullActionBuilder b) {\n    return b.mActionView.getParent() == null || b.mActionView.getParent() == layout;\n}","tryCatchPattern":"try {\n    pullLayout.setActionView(builder);\n} catch (RuntimeException e) {\n    ViewGroup old = (ViewGroup) builder.mActionView.getParent();\n    if (old != null) old.removeView(builder.mActionView);\n    pullLayout.setActionView(builder);\n}","preventionTips":["Create one action view and builder per pull layout/edge; never reuse across instances.","Don't pre-attach action views to temporary containers.","Check getParent() before setActionView."],"tags":["android","qmui","view-parent","illegal-state"],"backgroundTag":"invalid-state-transition","analyzedSha":"026e7d486677d6593a96689cd590ec3561176717","analyzedAt":"2026-09-06T13:32:24.816Z","contentChangedAt":"2026-09-06T13:32:24.816Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}