Android 如何在所需位置显示间隙
我正在开发一个壁纸应用程序。在it中,图像随按钮而变化。我想显示间隙时,用户几乎达到第10壁纸等。现在我正在使用这种方法进行填隙,它工作得很好,但通过这个填隙,当应用程序启动时会立即显示出来。我还希望在用户结束应用程序时插入。 这是代码Android 如何在所需位置显示间隙,android,admob,interstitial,Android,Admob,Interstitial,我正在开发一个壁纸应用程序。在it中,图像随按钮而变化。我想显示间隙时,用户几乎达到第10壁纸等。现在我正在使用这种方法进行填隙,它工作得很好,但通过这个填隙,当应用程序启动时会立即显示出来。我还希望在用户结束应用程序时插入。 这是代码 // Create the interstitial interstitial = new InterstitialAd(this, MY_INTERSTITIAL_UNIT_ID); // Create ad request AdRe
// Create the interstitial
interstitial = new InterstitialAd(this, MY_INTERSTITIAL_UNIT_ID);
// Create ad request
AdRequest adRequest = new AdRequest();
// Begin loading your interstitial
interstitial.loadAd(adRequest);
// Set Ad Listener to use the callbacks below
interstitial.setAdListener(this);
}
@Override public void onReceiveAd(Ad ad) {
Log.d("OK", "Received ad");
if (ad == interstitial) {
interstitial.show();
}
}
}
主要
请告诉我如何解决这个问题。Thanx调用此方法:-
public void displayInterstitial() {
if (interstitial.isLoaded()) {
interstitial.show();
}
}
在onClick()方法内部:-
在上面的onClick代码中使用if语句检查图像是否为10。包括
displayInterstitial();
如果是这样的话。它只会在第10张图像后显示间隙 你能用密码引导我吗。如何在onClick中编写if语句。谢谢
View.OnClickListener gButtonChangeImageListener = new OnClickListener() {
public void onClick(View v) {
currentImage--;
currentImage = (currentImage + images.length) % images.length;
hImageViewPic.setImageResource(images[currentImage]);
}
};
displayInterstitial();