如何在指定的java文件中添加admob横幅?

时间:2015-10-21 10:03:30

标签: admob

每个人,这是admob横幅代码:

AdView mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);

我在哪里可以将上面的代码放入以下代码并且有效? THX

jave代码如下:

http://pastebin.com/kB9tUCA5

1 个答案:

答案 0 :(得分:0)

您应该会看到Android的基本课程

 @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

        View rootView = inflater.inflate(R.layout.fragment_chat, container, false);

        if (savedInstanceState != null) {

            restore = savedInstanceState.getBoolean("restore");
            loading = savedInstanceState.getBoolean("loading");
            preload = savedInstanceState.getBoolean("preload");

        } else {

            App.getInstance().setCurrentChatId(chatId);

            restore = false;
            loading = false;
            preload = false;
        }

        AdView mAdView = (AdView) findViewById(R.id.adView);
        AdRequest adRequest = new AdRequest.Builder().build();
        mAdView.loadAd(adRequest);