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.
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:
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:
According to the current example of RecyclerView mode, it is displayed as a horizontal queue and QuickAdapter is the default data adapter of RecyclerView. Users are requested to make their own adjustments according to their own business needs.
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.
So far, the process of multiple advertisements has been added; the user list display logic has been isolated from multiple advertisements; and the user-defined process will not be affected by the display and configuration of advertisements.