Skip to main content

Draw信息流

一、简介#

主要介绍在Android项目中如何集成 TradPlus SDK的Draw信息流广告:

二、集成#

1、创建对象#

(1)V6.X新接口#

//AdUnitId 广告位ID,TradPlus后台创建
TPNative mTPNative = new TPNative(context, "AdUnitId");

(2)V5.X旧接口#

TradPlusView tradPlusView = new TradPlusView(context);
tradPlusView.setAdUnitId("AdUnitId");

2、设置监听#

(1)V6.X新接口#

mTPNative.setAdListener(new NativeAdListener() {
@Override
public void onAdClicked(TPAdInfo tpAdInfo) {
Log.i(TAG, "onAdClicked: ");
}
@Override
public void onAdLoaded(TPAdInfo tpAdInfo, TPBaseAd tpBaseAd) {
Log.i(TAG, "onAdLoaded: ");
//获取成功加载的数据
List<View> mDrawNativeAdList = mTPNative.getDrawNativeAdList();
//并将成功加载的数据插入到你们的数据列表中进行显示
}
@Override
public void onAdImpression(TPAdInfo tpAdInfo) {
Log.i(TAG, "onAdImpression: ");
}
@Override
public void onAdShowFailed(TPAdError error, TPAdInfo tpAdInfo) {
Log.i(TAG, "onAdShowFailed: ");
}
@Override
public void onAdLoadFailed(TPAdError error) {
Log.i(TAG, "onAdLoadFailed: ");
}
@Override
public void onAdClosed(TPAdInfo tpAdInfo) {
Log.i(TAG, "onAdClosed: ");
}
});

(2)V5.X旧接口#

tradPlusView.setAdViewListener(new TradPlusView.FSAdViewListener() {
@Override //广告加载成功
public void onAdViewLoaded(TradPlusView tradPlusView) {}
@Override //广告加载失败
public void onAdViewFailed(TradPlusView tradPlusView, TradPlusErrorCode tradPlusErrorCode) {}
@Override //广告被点击
public void onAdViewClicked(TradPlusView tradPlusView) {}
@Override
public void onAdViewExpanded(TradPlusView tradPlusView) {}
@Override
public void onAdViewCollapsed(TradPlusView tradPlusView) {}
@Override
public void onAdsSourceLoaded(Object o) {}
});
//设置DrawListVideo监听,监听三方返回的广告列表
tradPlusView.setDrawNativeListVideoView(new IDrawNativeListVideoViewListener() {
@Override
public void updateAdView(List list) {
//将该数据插入到你们的数据列表中进行显示
}
});

3、加载广告#

(1)V6.X新接口#

mTPNative.loadAd();

(2)V5.X旧接口#

tradPlusView.loadAd();