deckameron / Ti.Android.Admob

Appcelerator Android module wrapping Admob functionalities
17 stars 7 forks source link

Native ads in ListView #19

Open qasim90 opened 4 years ago

qasim90 commented 4 years ago

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

arifje commented 4 years ago

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.