Multiple

Multiple advertisements are suitable for interspersing advertisement content in the system ListView or RecyclerView list, keeping the style and layout consistent with the user, and perfectly integrating the advertisement type into the list layout.

Before you begin

You should finish the step of the Guide first.

This guide uses RecyclerView as a display example, and the related display process of ListView is the same.

Control initialization

First of all, based on the principle of multiple advertisement displays, before the list data is filled, the control initialization needs to be completed. The example is as follows:

public class CustomActivity extends AppCompatActivity {

    RecyclerView recyview;
    QuickAdapter adapter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.xml);
        initView();
        setCustomView();
    }


    private void initView() {
     recyview = findViewById(R.id.recyview);
    }

    private void setCustomView() {
        Adx3CustomAdView.getInstance().loadData(getApplicationContext(), "UnitId");
    }

}

List adapter added

After the initialization of the ad control is completed, according to the example, the user completes the initialization and data filling of the list control. The example is as follows:

Layout

The current layout is configured as a list layout and a single-item layout. According to the actual requirements of the business, the layout style and layout may be different. The reference example is as follows:

The current layout adopts the form of picture + text for page display.

Data adapter

After completing the layout and control initialization, for the list control, the following example shows the adapter filling and control-related event operations.

  • laodByUser - Parameter callback method, the current callback method is used to fill the user's own data, the user can configure the content of the non-advertising space, the current configuration is the content of the page text box.

  • loadUrl - Click the callback method, the current callback method can distinguish the user's own control or advertising space, the user can complete his own operation logic according to the current callback, and the operation of the advertising space does not affect the user's business process.

Last updated