Skip to content
This repository has been archived by the owner on Jul 14, 2021. It is now read-only.

适配器动态添加广告视图报错,麻烦看下是适配器 #508

Open
qinchangbiao opened this issue Jul 15, 2020 · 0 comments
Open

Comments

@qinchangbiao
Copy link

VirtualLayoutManager: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
at android.view.ViewGroup.addViewInner(ViewGroup.java:5104)
at android.view.ViewGroup.addView(ViewGroup.java:4929)
at android.view.ViewGroup.addView(ViewGroup.java:4869)
at android.view.ViewGroup.addView(ViewGroup.java:4842)
at zy.ads.engine.adapter.XSubContentAdapter.onBindViewHolder(XSubContentAdapter.java:100)
at zy.ads.engine.adapter.XSubContentAdapter.onBindViewHolder(XSubContentAdapter.java:33)

int type = getItemViewType(position);
    Log.e(TAG, "onBindViewHolder: position>>>>>" + +position + ", " + contentBeans.get(position).getTtne() + ", type:" + type);
    switch (type) {
        case TYPE_NEW://普通处理
            GlideUtils.loadImage(mContext, contentBeans.get(position).getThumbnail(), holder.imageView, R.mipmap.item_back);
            holder.name.setText(contentBeans.get(position).getTitle());
            holder.oldprice.setText(contentBeans.get(position).getReadNum() + "次阅读");
            holder.newprice.setText(String.valueOf(contentBeans.get(position).getPublishDate()));
            holder.frameLayout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent intent = new Intent(mContext, WedHItemDivActivity.class);
                    intent.putExtra(AppConstants.Item_id, contentBeans.get(position).getId());
                    mContext.startActivity(intent);
                }
            });
            break;
        case TYPE_AD:// 广告处理
            View expressAdView = contentBeans.get(position).getTtne().getExpressAdView();
            **holder.flRoot.removeAllViews();
            holder.flRoot.addView(expressAdView);//XSubContentAdapter.java:100**
            break;
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant