我创建了一个包含2个标签和Ad Mob的应用,我的问题是如何在第2个标签中集成插页式广告? ,表示按照Google AdMob policy限制每个用户操作后放置插页式广告,但是当我从第一个标签向第二个标签滑动时我想要添加全屏广告,并且当我从第二个标签滑动到第一个标签时限制广告标签。我怎样才能做到这一点? 通过示例和更正指导我!以下是我当前的活动。
boolean firstResume = true;
private ViewPager viewPager;
private FBTabsAdapter mAdapter;
private ActionBar actionBar;
Handler handler1 = new Handler();
private Context context;
private int i = 0;
private boolean exitAds = false;
// private Fragment _fragment;
// Tab titles
private String[] tabs = { "TAB 1", " TAB 2" };
@Override
protected void onResume() {
super.onResume();
if (!firstResume) {
} else {
firstResume = false;
}
}
@Override
public void onTabReselected(Tab tab, FragmentTransaction ft) {
}
@Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
// on tab selected
// show respected fragment view
viewPager.setCurrentItem(tab.getPosition());
if (tab.getPosition() == 1) {
Log.e("UPDATED", "DOWNLOADS SELECTED");
final DownloadsFragment fragment = ((DownloadsFragment) getSupportFragmentManager()
.findFragmentByTag("android:switcher:" + R.id.pager + ":1"));
fragment.updateDownloads();
// if (i == 0) {
// i++;
// } else if (i > 0) {
// }
} // else
// displayInterstitial();
}
@Override
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

TABS ADAPTER
package xxxxxx.xxxxxxxxxxx.xxxxxxxxx.com;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
public class ABTabsAdapter extends FragmentPagerAdapter {
public ABTabsAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int index) {
switch (index) {
case 0:
// Top Rated fragment activity
return new TAB1Fragment();
case 1:
// fragment activity
return new TAB2Fragment();
}
return null;
}
@Override
public int getCount() {
// get item count - equal to number of tabs
return 2;
}
}