Ti.Android.Admob icon indicating copy to clipboard operation
Ti.Android.Admob copied to clipboard

Native ads in ListView

Open qasim90 opened this issue 4 years ago • 1 comments

Is is possible to implement native ads as part of listview items like after each 10 items there is native ad box?

qasim90 avatar Apr 02 '20 09:04 qasim90

Also looking for an answer!

I solved this for the Ti.DFP module by creating a listView template like this;

'banner': {

	properties: {
		height: Ti.UI.SIZE,
		selectionStyle: Titanium.UI.iOS.ListViewCellSelectionStyle.NONE,
		className: 'bannerRow',
		name: 'bannerRow',
	},
	childTemplates: [
		{
			type: 'TiDfp.View',
			bindId: 'bannerView',
			properties: {
				height: Ti.UI.SIZE,
				adUnitId: 'xxx',
			}
        }
    ]
}

Note the "type: 'TiDfp.View'. Then you can create a new listView item, and add it where you want;

var bannerItem = [{
	template: "banner",
	properties: {
		id: 'bannerRow',
		canEdit: false,
		canMove: false,
		height: Ti.UI.SIZE,
		accessoryType: Ti.UI.LIST_ACCESSORY_TYPE_NONE
	},
}];

listView.sections[0].insertItemsAt(2, bannerItem, { animated : false, animationStyle: Titanium.UI.iOS.RowAnimationStyle.NONE});

I tried replacing TiDfp.View with TiAndroidAdmob.View, but this doesn't seem to work.

arifje avatar Sep 03 '20 08:09 arifje