如何在列表视图中实施Admob奖励视频广告?

时间:2019-03-04 05:07:07

标签: java android admob rewardedvideoad

我想知道如何在列表视图中实施AdMob奖励视频广告? 我正在使用here

中的源代码

,我想在此类中使用它StickerPackDetailsActivity.java 布局就会像这样

![layout] [1]

我想锁定添加到WhatsApp并通过观看视频奖励对其进行解锁。 但这是从

的listview显示的详细信息

![这里] [2]

那么,如何仅在列表视图的一个指定项目中实施视频奖励广告,而不是全部?

1 个答案:

答案 0 :(得分:-2)

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();
    }
}