是否可以在列表视图上的项目点击上显示admob插页式广告?

时间:2018-08-03 08:32:04

标签: android listview admob

是否可以在列表视图的项目点击上显示admob插页式广告? 我的应用上有一个listview。我想在用户单击listview的项目时显示admob插页式广告。这可能吗?如果可能的话,请给我代码。

1 个答案:

答案 0 :(得分:0)

listView = findViewById(R.id.listview); //put the id of u r listview
listView.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                if (mInterstitialAd.isLoaded()) {
                    mInterstitialAd.show();
                } else {
                    Log.d("TAG", "The interstitial wasn't loaded yet.");
                }
            }

            {

                mInterstitialAd.setAdListener(new AdListener() {
                    @Override
                    public void onAdLoaded() {
// Code to be executed when an ad finishes loading.
                    }

                    @Override
                    public void onAdFailedToLoad(int errorCode) {
// Code to be executed when an ad request fails.
                    }

                    @Override
                    public void onAdOpened() {
// Code to be executed when the ad is displayed.
                    }

                    @Override
                    public void onAdLeftApplication() {
// Code to be executed when the user has left the app.
                    }

                 //   @Override
                    public void onAdClosed() {
// Code to be executed when when the interstitial ad is closed.
                    }
                });
            }
        });