Help Center/Details/

Template rendering Feed Ads


Template rendering information flow advertisement: Supports graphic and video styles. Developers do not need to edit and render the advertisement styles by themselves. They can directly call the relevant interface to get the advertisement view to display. Developers can adjust the style of the selected template on the CSJ platform at any time. Under the premise of reducing access costs, the level of cpm will not be affected, and high competitiveness can still be maintained.
Supported ad sizes: Developers can select multiple templates and multiple sizes on the CSJ platform. Template rendering information flow ads support developers to adjust and edit
Note: Developers are not allowed to add buttons to the view and block ads.


Template feed ads: Provided by default
Template rendering information flow request method(TTNativeExpressAd)
Attention: The template ad request method requires the developer to set the setExpressViewAcceptedSize parameter in dp.
If the height is set to 0, the returned view will be highly adaptive according to the different templates checked on the platform.

Create TTAdNative object

//创建TTAdNative对象,createAdNative(Context context) context需要传入Activity对象
TTAdNative mTTAdNative = TTAdSdk.getAdManager().createAdNative(this);

Create ad request AdSlot

AdSlot adSlot = new AdSlot.Builder()
        .setCodeId(codeId) //广告位id
        .setAdCount(1) //请求广告数量为1到3条
        .setExpressViewAcceptedSize(expressViewWidth,0) //期望模板广告view的size,单位dp

Parameter description

Parameter Description
setCodeId The code ID created by the platform starts with 9 and 9 digits
setAdCount The number of requests is 1-3. It is recommended to set to 1
setExpressViewAcceptedSize Set the size of the request template creative unit: dp

Request ad

Call loadNativeExpressAd(AdSlot adSlot, @NonNull NativeExpressAdListener listener) to load ads asynchronously
Note: The click event registration time is before the ad render, otherwise it will affect the display and click data reporting

mTTAdNative.loadNativeExpressAd(adSlot, new TTAdNative.NativeExpressAdListener() {

    public void onError(int code, String message) {

    public void onNativeExpressAdLoad(List<TTNativeExpressAd> ads) {


NativeExpressAdListener Description

Callback Description
onError() Advertisement request failed callback The returned error code (code) indicates the reason for the failure of the advertisement request.See the link for details
onNativeExpressAdLoad() A callback for a successful ad request, the client can call render() in the callback for ad rendering

Ad click event listener

mTTAd.setExpressInteractionListener(new TTNativeExpressAd.ExpressAdInteractionListener() {
    public void onAdClicked(View view, int type) {

    public void onAdShow(View view, int type) {

    public void onRenderFail(View view, String msg, int code) {

    public void onRenderSuccess(View view, float width, float height) {

ExpressAdInteractionListener Description

Callback Description
onAdClicked() The callback of the ad click, the action after the click is controlled by the sdk.
onAdShow() Advertisement display callback, display volume can be counted in the method provided by CSJ
onRenderFail() Personalized template rendering failed
onRenderSuccess() The personalized template is rendered successfully, the client can directly add the view of the advertisement to the control to be displayed in the callback

Dislike Monitor
The dislike logic helps us to improve the advertising experience and match, please follow the access instructions to set:
The following logic is the logic in the CSJ version 3500 SDK. SDK developers below 3500 version can refer to the corresponding demo for integration

         * 设置广告的不喜欢,开发者可自定义样式
         * @param ad
         * @param customStyle 是否自定义样式,true:样式自定义
        private void bindDislike(TTNativeExpressAd ad, boolean customStyle) {
        if (customStyle) {
            final DislikeInfo dislikeInfo = ad.getDislikeInfo();
            if (dislikeInfo == null || dislikeInfo.getFilterWords() == null || dislikeInfo.getFilterWords().isEmpty()) {
            final DislikeDialog dislikeDialog = new DislikeDialog(this, dislikeInfo);
            dislikeDialog.setOnDislikeItemClick(new DislikeDialog.OnDislikeItemClick() {
                public void onItemClick(FilterWord filterWord) {
          , "点击 " + filterWord.getName());
            dislikeDialog.setOnPersonalizationPromptClick(new DislikeDialog.OnPersonalizationPromptClick() {
                public void onClick(PersonalizationPrompt personalizationPrompt) {
          , "点击了为什么看到此广告");
        ad.setDislikeCallback(BannerExpressActivity.this, new TTAdDislike.DislikeInteractionCallback() {
            public void onShow() {


            public void onSelected(int position, String value, boolean enforce) {
      , "点击 " + value);
                if (enforce) {
          , "模版Banner 穿山甲sdk强制将view关闭了");

            public void onCancel() {
      , "点击取消 ");

            public void onRefuse() {



DislikeInteractionCallback Description

Callback Description
onItemClick() Callback when the user clicks on filterWord in the case of a custom style
onClick() In the case of custom styles, the user clicked "Why see this ad"
onSelected() The default dislike style, click filterWord to call back. The developer can remove the ad in this callback
onShow() Default dislike style, dislike pop-up window shows back
onCancel() Default dislike style, click to cancel callback
onRefuse() The default dislike style, the user repeatedly clicks the dislike button to call back. 3600 version abolished

Destroy the ad object

Ads that have been displayed and are no longer used need to call the destroy method to destroy the ads in time to avoid excessive memory usage.

    protected void onDestroy() {
        if (mTTAd != null) {

Reference Demo

For the detailed code of the information flow of the personalized template, please refer to NativeExpressActivity in the Demo. If you use it in the information flow scenario, refer to NativeExpressListActivity.

Note on template rendering information flow:

1、In the parameter setting of the template size setExpressViewAcceptedSize, if the height is set to 0, the height will be adaptive
2、The template information flow closed pop-up window does not support removing, the dislike logic helps to improve the advertising experience and matching degree
3、The registration time of the click event of the advertisement needs to be before the advertisement render, otherwise it will affect the display and click data reporting.

Did the content solve your problem?
Contact us