我在 ListView 中有 AdMob,一切正常,但是......
假设 AdMob 位于位置 0,完全位于顶部,然后我正在滚动列表,所以我看不到我的 AdMob。当我返回列表顶部时,总是会再次加载 AdMob。
如何“保留”我的 AdMob 以避免在我的 ListView 中重新加载 AdMob?我需要 AdListener 吗?
谢谢!
更新:我在 Java 类中添加 AdMob,如下所示:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.list_item, parent, false);
if (isItemAnAd(position)) {
if (rowView instanceof AdView) {
return rowView;
} else {
Activity activity = (Activity) context;
adView = new AdView(activity, AdSize.BANNER,
AD_UNIT_ID_LISTVIEW_MAIN);
adView.setLayoutParams(params);
AdRequest adRequest = new AdRequest();
adView.loadAd(adRequest);
rowView = adView;
return adView;
}
} else {
...Standard View...