android中底部工作表对话框中的AdMob(移动广告)错误
任何人都可以在这方面帮助我,我制作了一个应用程序&我在应用程序中使用了底部工作表对话框,现在我需要将ADMob添加到其中一行&我做了xml部分,但在与底部工作表相关的活动页面中,我仍然有一个错误。 下面是包含AdMob部分的底页的Java代码。。。。请告知android中底部工作表对话框中的AdMob(移动广告)错误,android,Android,任何人都可以在这方面帮助我,我制作了一个应用程序&我在应用程序中使用了底部工作表对话框,现在我需要将ADMob添加到其中一行&我做了xml部分,但在与底部工作表相关的活动页面中,我仍然有一个错误。 下面是包含AdMob部分的底页的Java代码。。。。请告知 private BottomSheetListener mListener; private TextView aboutSheet; private ImageView DuctLiteImage, DuctFul
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);
在您的代码中使用
getActivity()
而不是this
,或者从您的父活动中分发一个Context
。非常感谢它的有效性