gpt4 book ai didi

java - InterstitialAd的构造函数

转载 作者:行者123 更新时间:2023-11-29 04:43:36 25 4
gpt4 key购买 nike

我正在尝试将 InterstitialAd 集成到我的应用程序 fragment 之一中。我正在关注它的官方网站,但如果我输入如下代码,它会给我错误,如 The constructor InterstitialAd(AuthorListFragment) is undefined

The constructor InterstitialAd(MyListFragment) is undefined

我的完整代码如下。

public View onCreateView(LayoutInflater inflater, ViewGroup group,Bundle savedState){
super.onCreateView(inflater,group,savedState);

return inflater.inflate(R.layout.fragment_home,null);


mInterstitialAd = new InterstitialAd(this);
mInterstitialAd.setAdUnitId("ca-app-pub-3940256099942544/1033173712");
final AdRequest adRequest = new AdRequest.Builder()
.addTestDevice("7C77ADF1D83FA8B87C0481D6748FA4DB")
.build();
mInterstitialAd.loadAd(adRequest);

mInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice("7C77ADF1D83FA8B87C0481D6748FA4DB")
.build();
mInterstitialAd.loadAd(adRequest);
}
});
}

我缺少什么?

感谢您的帮助:)

最佳答案

public View onCreateView(LayoutInflater inflater, ViewGroup group,Bundle savedState){
super.onCreateView(inflater,group,savedState);

//return inflater.inflate(R.layout.fragment_home,null);
// take this to end

mInterstitialAd = new InterstitialAd(getActivity());
mInterstitialAd.setAdUnitId("ca-app-pub-3940256099942544/1033173712");
final AdRequest adRequest = new AdRequest.Builder()
.addTestDevice("7C77ADF1D83FA8B87C0481D6748FA4DB")
.build();
mInterstitialAd.loadAd(adRequest);

mInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice("7C77ADF1D83FA8B87C0481D6748FA4DB")
.build();
mInterstitialAd.loadAd(adRequest);
}
});
return inflater.inflate(R.layout.fragment_home,null);

}

关于java - InterstitialAd的构造函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38223441/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com