我需要在点击 3 次后重新加载插页式广告,而不是每次广告关闭后重新加载。
retrybutton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mInterstitialAd.isLoaded()) {
mInterstitialAd.show();
} else {
START();
}
}
});
mInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
// Load the next interstitial.
mInterstitialAd.loadAd(new AdRequest.Builder().build());
}
});
每次我点击重试
按钮时,都会显示一个广告;那不是我需要的。我需要它在点击 3 次后显示。
最佳答案
您只需跟踪点击次数,并仅在点击次数达到 3 时才显示新广告:
private int numberOfClicksOnRetryButton = 0;
...
retrybutton.setOnClickListener(new View.OnClickListener() {
@Override
public synchronized void onClick(View v) {
if (mInterstitialAd.isLoaded()) {
numberOfClicksOnRetryButton++;
if (numberOfClicksOnRetryButton == 3) {
// This line is reached if the button has been clicked three times
mInterstitialAd.show();
numberOfClicksOnRetryButton = 0;
}
} else {
...
}
}
});
关于java - 如何每 3 次点击而不是每次广告关闭时重新加载广告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55970490/