问题描述
我想知道如何在列表视图中实施AdMob奖励视频广告吗? 我正在从使用源代码
我想在此类StickerPackDetailsActivity.java中使用它,布局会像这样
![layout] [1]
我想锁定添加到WhatsApp并通过观看视频奖励对其进行解锁。 但是这个标签的细节从列表视图显示
![这里] [2]
那么,如何仅在列表视图的一个指定项中而不是全部实施视频奖励广告?
1楼
public class MainActivity extends AppCompatActivity implements RewardedVideoAdListener {
private RewardedVideoAd mRewardedVideoAd;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MobileAds.initialize(this,"ca-app-pub111111111");
mRewardedVideoAd = MobileAds.getRewardedVideoAdInstance(this);
listitem.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
loadRewardedVideoAd();
}
});
}
private void loadRewardedVideoAd() {
mRewardedVideoAd.loadAd("ca-app-pub-",
new AdRequest.Builder().build());
}
@Override
public void onRewardedVideoAdLoaded() {
}
@Override
public void onRewardedVideoAdOpened() {
}
@Override
public void onRewardedVideoStarted() {
}
@Override
public void onRewardedVideoAdClosed() {
loadRewardedVideoAd();
}
@Override
public void onRewarded(RewardItem rewardItem) {
}
@Override
public void onRewardedVideoAdLeftApplication() {
}
@Override
public void onRewardedVideoAdFailedToLoad(int i) {
}
@Override
public void onRewardedVideoCompleted() {
}
@Override
protected void onPause() {
mRewardedVideoAd.pause(this);
super.onPause();
}
@Override
protected void onResume() {
mRewardedVideoAd.resume(this);
super.onResume();
}
}