{"record":{"id":"984d4d37bbf425b8","repo":"Tencent/QMUI_Android","slug":"you-should-call-view-to-set-your-content-view","errorCode":null,"errorMessage":"you should call view() to set your content view","messagePattern":"you should call view\\(\\) to set your content view","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"qmui/src/main/java/com/qmuiteam/qmui/widget/popup/QMUINormalPopup.java","lineNumber":363,"sourceCode":"            return x - anchorRootLocation[0];\n        }\n\n        int getWindowY() {\n            return y - anchorRootLocation[1];\n        }\n    }\n\n    private boolean shouldShowShadow() {\n        return mAddShadow && QMUILayoutHelper.useFeature();\n    }\n\n    public T show(@NonNull View anchor) {\n        return show(anchor, 0, 0, anchor.getWidth(), anchor.getHeight());\n    }\n\n    public T show(@NonNull View anchor, int anchorAreaLeft, int anchorAreaTop, int anchorAreaRight, int anchorAreaBottom){\n        if (mContentView == null) {\n            throw new RuntimeException(\"you should call view() to set your content view\");\n        }\n        decorateContentView();\n        ShowInfo showInfo = new ShowInfo(anchor, anchorAreaLeft, anchorAreaTop, anchorAreaRight, anchorAreaBottom);\n        calculateWindowSize(showInfo);\n        calculateXY(showInfo);\n        adjustShowInfo(showInfo);\n        mDecorRootView.setShowInfo(showInfo);\n        setAnimationStyle(showInfo.anchorProportion(), showInfo.direction);\n        mWindow.setWidth(showInfo.windowWidth());\n        mWindow.setHeight(showInfo.windowHeight());\n        showAtLocation(anchor, showInfo.getWindowX(), showInfo.getWindowY());\n        return (T) this;\n    }\n\n    private void decorateContentView() {\n        ContentView contentView = ContentView.wrap(mContentView, mInitWidth, mInitHeight);\n        QMUISkinValueBuilder builder = QMUISkinValueBuilder.acquire();\n        if (mIsBorderColorSet) {","sourceCodeStart":345,"sourceCodeEnd":381,"githubUrl":"https://github.com/Tencent/QMUI_Android/blob/026e7d486677d6593a96689cd590ec3561176717/qmui/src/main/java/com/qmuiteam/qmui/widget/popup/QMUINormalPopup.java#L345-L381","documentation":"QMUINormalPopup.show(anchor, ...) throws a RuntimeException when mContentView is null, i.e. view() was never called to supply the popup's content. The popup cannot compute its window size or position without content.","triggerScenarios":"Calling popup.show(anchor) (any overload) before popup.view(contentView) has been invoked; reusing a popup builder instance where the view() call was skipped or the content view was never assigned.","commonSituations":"Showing the popup from a click handler while configuration happens asynchronously later; forgetting view() because another popup type (e.g. fullscreen popup) uses addView() instead.","solutions":["Call popup.view(contentView) before popup.show(anchor).","If content is built asynchronously, defer show() until the content view is ready.","Guard the show() call with a null check on the content you intend to pass."],"exampleFix":"// before\nQMUINormalPopup popup = QMUINormalPopup.create(context);\npopup.show(anchor); // crashes: content not set\n// after\nQMUINormalPopup popup = QMUINormalPopup.create(context)\n        .view(R.layout.popup_content);\npopup.show(anchor);","handlingStrategy":"validation","validationCode":"if (contentView != null) {\n    popup.view(contentView).show(anchor);\n}","typeGuard":null,"tryCatchPattern":"try {\n    popup.show(anchor);\n} catch (RuntimeException e) {\n    Log.e(TAG, \"call view() before show() on QMUINormalPopup\", e);\n}","preventionTips":["Chain builder calls: QMUINormalPopup.create(ctx).view(R.layout.x).show(anchor).","Never call show() before view(); enforce with a builder helper method.","For async content, invoke show() in the completion callback, not upfront."],"tags":["android","qmui","popup","missing-content"],"backgroundTag":"empty-required-field","analyzedSha":"026e7d486677d6593a96689cd590ec3561176717","analyzedAt":"2026-09-06T13:32:24.816Z","contentChangedAt":"2026-09-06T13:32:24.816Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}