private void initRecyclerViewItems() {
        rvMessages = (RecyclerView) findViewById(R.id.rvMessages);
        rvMessages.setLayoutManager(new LinearLayoutManager(this));

        //creating your adapter, it could be a custom adapter as well
        RecyclerExampleAdapter adapter  = new RecyclerExampleAdapter(this);

        //your test devices' ids
        String[] testDevicesIds = new String[]{getString(R.string.testDeviceID),AdRequest.DEVICE_ID_EMULATOR};
        //when you'll be ready for release please use another ctor with admobReleaseUnitId instead.
        adapterWrapper = AdmobExpressRecyclerAdapterWrapper.builder(this)
                .setLimitOfAds(10)
                .setFirstAdIndex(2)
                .setNoOfDataBetweenAds(10)
                .setTestDeviceIds(testDevicesIds)
                .setAdapter(adapter)
                .setAdViewWrappingStrategy(new AdViewWrappingStrategyBase() {
                    @NonNull
                    @Override
                    protected ViewGroup getAdViewWrapper(ViewGroup parent) {
                        return (ViewGroup) LayoutInflater.from(parent.getContext()).inflate(R.layout.web_ad_container,
                                parent, false);
                    }

                    @Override
                    protected void recycleAdViewWrapper(@NonNull ViewGroup wrapper, @NonNull NativeExpressAdView ad) {
                        //get the view which directly will contain ad
                        ViewGroup container = (ViewGroup) wrapper.findViewById(R.id.ad_container);
                        //iterating through all children of the container view and remove the first occured {@link NativeExpressAdView}. It could be different with {@param ad}!!!*//*
                        for (int i = 0; i < container.getChildCount(); i++) {
                            View v = container.getChildAt(i);
                            if (v instanceof NativeExpressAdView) {
                                container.removeViewAt(i);
                                break;
                            }
                        }
                    }

                    @Override
                    protected void addAdViewToWrapper(@NonNull ViewGroup wrapper, @NonNull NativeExpressAdView ad) {
                        //get the view which directly will contain ad
                        ViewGroup container = (ViewGroup) wrapper.findViewById(R.id.ad_container);
                        //add the {@param ad} directly to the end of container*//*
                        container.addView(ad);
                    }
                })
                .build();

        rvMessages.setAdapter(adapterWrapper); // setting an AdmobBannerRecyclerAdapterWrapper to a RecyclerView
        //use the following commented block to use a grid layout with spanning ad blocks
       /* GridLayoutManager mLayoutManager = new GridLayoutManager(this, 2);
        mLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
            @Override
            public int getSpanSize(int position) {
                if(adapterWrapper.getItemViewType(position) == adapterWrapper.getViewTypeAdExpress())
                    return 2;
                else return 1;
            }
        });
        rvMessages.setLayoutManager(mLayoutManager);*/

        //preparing the collection of data
        final String sItem = "item #";
        ArrayList<String> lst = new ArrayList<String>(100);
        for(int i=1;i<=100;i++)
            lst.add(sItem.concat(Integer.toString(i)));

        //adding a collection of data to your adapter and rising the data set changed event
        adapter.addAll(lst);
        adapter.notifyDataSetChanged();
    }
private void initRecyclerViewItems() {
        rvMessages = (RecyclerView) findViewById(R.id.rvMessages);
        rvMessages.setLayoutManager(new LinearLayoutManager(this));

        
        RecyclerExampleAdapter adapter  = new RecyclerExampleAdapter(this);

        
        String[] testDevicesIds = new String[]{getString(R.string.testDeviceID),AdRequest.DEVICE_ID_EMULATOR};
        
        adapterWrapper = AdmobExpressRecyclerAdapterWrapper.builder(this)
                .setLimitOfAds(10)
                .setFirstAdIndex(2)
                .setNoOfDataBetweenAds(10)
                .setTestDeviceIds(testDevicesIds)
                .setAdapter(adapter)
                .setAdViewWrappingStrategy(new AdViewWrappingStrategyBase() {
                    @NonNull
                    @Override
                    protected ViewGroup getAdViewWrapper(ViewGroup parent) {
                        return (ViewGroup) LayoutInflater.from(parent.getContext()).inflate(R.layout.web_ad_container,
                                parent, false);
                    }

                    @Override
                    protected void recycleAdViewWrapper(@NonNull ViewGroup wrapper, @NonNull NativeExpressAdView ad) {
                        
                        ViewGroup container = (ViewGroup) wrapper.findViewById(R.id.ad_container);
                        

        
        final String sItem = "item #";
        ArrayList<String> lst = new ArrayList<String>(100);
        for(int i=1;i<=100;i++)
            lst.add(sItem.concat(Integer.toString(i)));

        
        adapter.addAll(lst);
        adapter.notifyDataSetChanged();
    }
private void initRecyclerViewItems ( ) { rvMessages = ( RecyclerView ) findViewById ( R . id . rvMessages ) ; rvMessages . setLayoutManager ( new LinearLayoutManager ( this ) ) ; //creating your adapter, it could be a custom adapter as well RecyclerExampleAdapter adapter = new RecyclerExampleAdapter ( this ) ; //your test devices' ids String [ ] testDevicesIds = new String [ ] { getString ( R . string . testDeviceID ) , AdRequest . DEVICE_ID_EMULATOR } ; //when you'll be ready for release please use another ctor with admobReleaseUnitId instead. adapterWrapper = AdmobExpressRecyclerAdapterWrapper . builder ( this ) . setLimitOfAds ( 10 ) . setFirstAdIndex ( 2 ) . setNoOfDataBetweenAds ( 10 ) . setTestDeviceIds ( testDevicesIds ) . setAdapter ( adapter ) . setAdViewWrappingStrategy ( new AdViewWrappingStrategyBase ( ) { @ NonNull @ Override protected ViewGroup getAdViewWrapper ( ViewGroup parent ) { return ( ViewGroup ) LayoutInflater . from ( parent . getContext ( ) ) . inflate ( R . layout . web_ad_container , parent , false ) ; } @ Override protected void recycleAdViewWrapper ( @ NonNull ViewGroup wrapper , @ NonNull NativeExpressAdView ad ) { //get the view which directly will contain ad ViewGroup container = ( ViewGroup ) wrapper . findViewById ( R . id . ad_container ) ; //iterating through all children of the container view and remove the first occured {@link NativeExpressAdView}. It could be different with {@param ad}!!!*//* for ( int i = 0 ; i < container . getChildCount ( ) ; i ++ ) { View v = container . getChildAt ( i ) ; if ( v instanceof NativeExpressAdView ) { container . removeViewAt ( i ) ; break ; } } } @ Override protected void addAdViewToWrapper ( @ NonNull ViewGroup wrapper , @ NonNull NativeExpressAdView ad ) { //get the view which directly will contain ad ViewGroup container = ( ViewGroup ) wrapper . findViewById ( R . id . ad_container ) ; //add the {@param ad} directly to the end of container*//* container . addView ( ad ) ; } } ) . build ( ) ; rvMessages . setAdapter ( adapterWrapper ) ; // setting an AdmobBannerRecyclerAdapterWrapper to a RecyclerView //use the following commented block to use a grid layout with spanning ad blocks /* GridLayoutManager mLayoutManager = new GridLayoutManager(this, 2);
        mLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
            @Override
            public int getSpanSize(int position) {
                if(adapterWrapper.getItemViewType(position) == adapterWrapper.getViewTypeAdExpress())
                    return 2;
                else return 1;
            }
        });
        rvMessages.setLayoutManager(mLayoutManager);*/ //preparing the collection of data final String sItem = "item #" ; ArrayList < String > lst = new ArrayList < String > ( 100 ) ; for ( int i = 1 ; i <= 100 ; i ++ ) lst . ( sItem . concat ( Integer . toString ( i ) ) ) ; //adding a collection of data to your adapter and rising the data set changed event adapter . addAll ( lst ) ; adapter . notifyDataSetChanged ( ) ; }
Inits an adapter with items, wrapping your adapter with a {@link AdmobExpressRecyclerAdapterWrapper} and setting the recyclerview to this wrapper
FIRST OF ALL Please notice that the following code will work on a real devices but emulator!
Inits an adapter with items wrapping your adapter with a {