Android SDK Advanced Usage


RecyclerViewAdPlacer is used for displaying dynamic banner ads in RecyclerViews. Dynamic banner ads have their own predefined positions thus, they will not be loaded until the user scrolls to that specific position.

This comes a few advantages:

  1. Loading banner ads not at the initial screen load, but rather on user scroll action increases load time performance of your screens.
  2. Loading banner ads only when they will be visible to user, increases viewability metrics.
  3. Predefined positions can be updated without the need of sending a new app update, which gives the app owners ability to change the banner positions even when the app is live.
  4. As the banners are displayed dynamically, app owners can remove the banners from certain pages without the need of a new app update. Just like changing banner positions, this can also be done while the app is live.

Loading and displaying of banner ads are handled within RecyclerViewAdPlacer which makes integration of banner ads quite easy.


Step 1: After creating your RecyclerView and setting its adapter and layout manager properties create a RecyclerViewAdPlacer object.

Step 2: Once the RecyclerViewAdPlacer object is created, set its adCategories and pass your RecyclerView to the setRecyclerView function.

Step 3: Finally call your adPlacer's notifyDataSetChanged() method.

Done: That's it! Now your app is ready to show dynamic banner ads.

Full Example

public class MyActivity extends AppCompatActivity() {
private RecyclerView mRecyclerView;
private RecyclerViewAdPlacer adPlacer;
@Override protected void onCreate(Bundle savedInstanceState) {
// Set layout manager and adapter of your recyclerview
// ...
adPlacer = new RecyclerViewAdPlacer(getApplicationContext());
@Override protected void onResume() {
adPlacer.recyclerViewIsVisible(); // Enable auto refresh on loaded banner ads
@Override protected void onPause() {
adPlacer.recyclerViewIsInvisible(); // Disable auto refresh on loaded banner ads
private void loadPage() {
// Populate your data to be displayed
// ...