Tencent/QMUI_Android · error · IllegalStateException

the view create by onCreateContentView() should implement fr

Error message

the view create by onCreateContentView() should implement from IQMUIContinuousNestedBottomView

What it means

QMUIContinuousNestedBottomDelegateLayout's constructor calls onCreateContentView() and requires the returned View to implement IQMUIContinuousNestedBottomView, since the layout delegates nested scrolling calls to that interface. If it does not, an IllegalStateException is thrown during construction.

Source

Thrown at qmui/src/main/java/com/qmuiteam/qmui/nestedScroll/QMUIContinuousNestedBottomDelegateLayout.java:96

    public QMUIContinuousNestedBottomDelegateLayout(Context context) {
        this(context, null);
    }

    public QMUIContinuousNestedBottomDelegateLayout(Context context, AttributeSet attrs) {
        this(context, null, 0);
    }

    public QMUIContinuousNestedBottomDelegateLayout(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);

        mParentHelper = new NestedScrollingParentHelper(this);
        mChildHelper = new NestedScrollingChildHelper(this);

        ViewCompat.setNestedScrollingEnabled(this, true);
        mHeaderView = onCreateHeaderView();
        mContentView = onCreateContentView();
        if (!(mContentView instanceof IQMUIContinuousNestedBottomView)) {
            throw new IllegalStateException("the view create by onCreateContentView() " +
                    "should implement from IQMUIContinuousNestedBottomView");
        }
        addView(mHeaderView, new FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, getHeaderHeightLayoutParam()));
        addView(mContentView, new FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
        mHeaderViewOffsetHelper = new QMUIViewOffsetHelper(mHeaderView);
        mContentViewOffsetHelper = new QMUIViewOffsetHelper(mContentView);
        mViewFlinger = new ViewFlinger();
    }

    public View getHeaderView() {
        return mHeaderView;
    }

    public View getContentView() {
        return mContentView;
    }

View on GitHub (pinned to 026e7d4866)

Solutions

  1. Return a view implementing IQMUIContinuousNestedBottomView, such as QMUIContinuousNestedBottomRecyclerView.
  2. Wrap your custom view in a class implementing IQMUIContinuousNestedBottomView and forward its methods.
  3. If a plain scrollable is needed, use the library-provided bottom view subclasses.

Example fix

// before
override fun onCreateContentView(): View = RecyclerView(context) // throws
// after
override fun onCreateContentView(): View = QMUIContinuousNestedBottomRecyclerView(context)
Defensive patterns

Strategy: validation

Validate before calling

override fun onCreateContentView(): View {
  val v = ... // your view
  require(v is IQMUIContinuousNestedBottomView) { "content view must implement IQMUIContinuousNestedBottomView" }
  return v
}

Type guard

fun View?.isContinuousNestedBottom(): Boolean = this is IQMUIContinuousNestedBottomView

Prevention

When it happens

Trigger: Subclassing QMUIContinuousNestedBottomDelegateLayout and overriding onCreateContentView() to return a View (e.g. plain RecyclerView, WebView, LinearLayout) that does not implement IQMUIContinuousNestedBottomView.

Common situations: Returning a raw RecyclerView instead of the library's QMUIContinuousNestedBottomRecyclerView; custom content views written before reading the interface contract; copy-paste from the header-side subclass where no such interface is required.

Understand the failure class

Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.

Related errors


AI-assisted analysis of Tencent/QMUI_Android@026e7d4866 (2026-09-06). Data as JSON: /api/errors/6809f4c18532a982. Report an issue: GitHub.