首页 > 解决方案 > android中底部工作表对话框中的AdMob(移动广告)错误

问题描述

任何人都可以帮助我,我制作了一个应用程序,我在应用程序中使用了一个底页对话框,现在我需要将 ADMob 添加到其中一行中,我做了 xml 部分,但是在与底页相关的活动页面中我仍然有一个错误。 在此处输入图像描述

这是带有 AdMob 部分的底部工作表的 Java 代码....请告知

    private BottomSheetListener mListener;
    private TextView aboutSheet;
    private ImageView DuctLiteImage, DuctFullImage, ourAppArrow;
    private CardView aboutUsCard, storeGoogleCard, ductLiteCard, ductFullCard, recommendedCard, contactUsCard, ourApps;
    private TextView ductSizerLite, ductSizerFull, storeGoogle, recommendedStore, contactUs;
    LinearLayout ductLiteLayout, ductFullLayout;
    AdView mAdView;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.bottom_sheet_layout, container, false);
        CardView aboutUsCard = v.findViewById(R.id.about_us_card);
        CardView storeGoogleCard = v.findViewById(R.id.store_card);
        CardView ductLiteCard=v.findViewById(R.id.duct_lite_card);
        CardView ductFullCard=v.findViewById(R.id.duct_full_card);
        CardView recommendedCard=v.findViewById(R.id.recommended_card);
        CardView contactUsCard=v.findViewById(R.id.conract_us_card);
        CardView ourApps=v.findViewById(R.id.our_apps_card);
        LinearLayout ductLiteLayout = v.findViewById(R.id.lite_Linear);
        LinearLayout ductFullLayout = v.findViewById(R.id.full_layout);
        ImageView  ourAppArrow = v.findViewById(R.id.ourapp_arrow);

        MobileAds.initialize(this, new OnInitializationCompleteListener() {
            @Override
            public void onInitializationComplete(InitializationStatus initializationStatus) {
            }
        });

        mAdView = v.findViewById(R.id.adView);
        AdRequest adRequest = new AdRequest.Builder().build();
        mAdView.loadAd(adRequest);

标签: android

解决方案


在您的代码中使用getActivity()而不是从您的父活动中传递一个。thisContext


推荐阅读