我可以在不同页面的项目中使用FB和Admob广告吗?

问题描述 投票:-5回答:2

我在另一个页面上使用了谷歌浏览器,但我想使用fb受众网络横幅广告,但它显示错误。我的代码是:

  adView = new AdView(BhaktiPlayer.this, "539967309761431_541729399585222", AdSize.RECTANGLE_HEIGHT_250);

        // Find the Ad Container
        LinearLayout adContainer = (LinearLayout) findViewById(R.id.banner_container);
        // Add the ad view to your activity layout
        adContainer.addView(adView);
        // Request an ad
        adView.loadAd();

并显示错误:

Error:(57, 48) error: incompatible types: String cannot be converted to AttributeSet

Error:(64, 15) error: method loadAd in class BaseAdView cannot be applied to given types;
required: AdRequest
found: no arguments
reason: actual and formal argument lists differ in length
android google-admob facebook-audience-network
2个回答
2
投票

你可能需要命令notifyDataSetChanged();你有没有看过that

RecyclerView不提供默认更新方法,由您自己每次调用它,这为您提供了更大的灵活性。

正如帖子解释的那样,您需要将方法调用到更新视图的适配器中

public void updateData(ArrayList<ViewModel> viewModels) {
   items.clear();
   items.addAll(viewModels);
   notifyDataSetChanged();
}

0
投票

当您从firebase手动更改任何内容时,它将不会在您的应用程序中生效,因为您的应用程序不知道您手动完成的操作,除非您从代码中执行此操作。如果你从代码中执行它,那么notifyDataSetChanged()就是你的方法。

© www.soinside.com 2019 - 2024. All rights reserved.