英文:
error: cannot find symbol method setAdListener(<anonymous InterstitialAdListener>) & (<anonymous InterstitialAdListener>)
问题
error: 无法找到符号方法 setAdListener(<匿名 AdListener>)
error: 无法找到符号方法 setAdListener(<匿名 InterstitialAdListener>)
com.facebook.ads.AdView adView_banner = new com.facebook.ads.AdView(this, getString(R.string.facebook_banner_id), AdSize.BANNER_HEIGHT_50);
// 找到广告容器
LinearLayout adContainer = (LinearLayout) findViewById(R.id.adView);
// 将广告视图添加到您的活动布局
adContainer.addView(adView_banner);
adView_banner.setAdListener(new com.facebook.ads.AdListener() {
@Override
public void onError(Ad ad, AdError adError) {
Log.i("ERR", "" + adError.getErrorMessage());
}
});
英文:
error: cannot find symbol method setAdListener(<anonymous AdListener>)
error: cannot find symbol method setAdListener(<anonymous InterstitialAdListener>)
com.facebook.ads.AdView adView_banner = new com.facebook.ads.AdView(this, getString(R.string.facebook_banner_id), AdSize.BANNER_HEIGHT_50);
// Find the Ad Container
LinearLayout adContainer = (LinearLayout) findViewById(R.id.adView);
// Add the ad view to your activity layout
adContainer.addView(adView_banner);
adView_banner.setAdListener(new com.facebook.ads.AdListener() {
@Override
public void onError(Ad ad, AdError adError) {
Log.i("ERR",""+adError.getErrorMessage());
}
答案1
得分: 1
Facebook已更新其当前的SDK,针对您的情况,您需要更改您的代码以引用以下链接:
https://developers.facebook.com/docs/audience-network/guides/ad-formats/banner/android
AdListener adListener = new AdListener() {
@Override
public void onError(Ad ad, AdError adError) {
// 广告错误回调
Toast.makeText(
MainActivity.this,
"错误:" + adError.getErrorMessage(),
Toast.LENGTH_LONG)
.show();
}
@Override
public void onAdLoaded(Ad ad) {
// 广告加载完成回调
}
@Override
public void onAdClicked(Ad ad) {
// 广告被点击回调
}
@Override
public void onLoggingImpression(Ad ad) {
// 广告展示印象被记录回调
}
};
// 请求广告
adView.loadAd(adView.buildLoadAdConfig().withAdListener(adListener).build());
英文:
Facebook has updated their current SDK, for your case change your code to
reference
https://developers.facebook.com/docs/audience-network/guides/ad-formats/banner/android
AdListener adListener = new AdListener() {
@Override
public void onError(Ad ad, AdError adError) {
// Ad error callback
Toast.makeText(
MainActivity.this,
"Error: " + adError.getErrorMessage(),
Toast.LENGTH_LONG)
.show();
}
@Override
public void onAdLoaded(Ad ad) {
// Ad loaded callback
}
@Override
public void onAdClicked(Ad ad) {
// Ad clicked callback
}
@Override
public void onLoggingImpression(Ad ad) {
// Ad impression logged callback
}
};
// Request an ad
adView.loadAd(adView.buildLoadAdConfig().withAdListener(adListener).build());
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论