android - inflate view in adapter -


in code have condistion. if inmobi ads reqeust success show inmoby ads if failed show google ads.

here code

@override   public view getview(int positioninlist, view convertview, final viewgroup parent) {     if (adsfreq != 0 && positioninlist > 0 && (positioninlist + 1) % adsfreq == 0) {       mconvertview = convertview;       if (mconvertview == null) {         mconvertview = vi.inflate(r.layout.banner_inmobi_container,parent,false);       }       imbanner banneradview = (imbanner)mconvertview.findviewbyid(r.id.bannerview);       adutils.getinstance().loadinmobibanner(banneradview, new iadlistener() {         @override         public void onfail() {           mconvertview = vi.inflate(r.layout.banner_container, parent, false);           adview madview = (adview) mconvertview.findviewbyid(r.id.adview);           madview.loadad(adutils.getadmobrequestforcurrentuser());         }       });       return mconvertview;     } } 

when inmobi request inmob ads shows when request failed googleads showing @ all.

for test put code alone , it's worked well.

mconvertview = vi.inflate(r.layout.banner_container, parent, false);           adview madview = (adview) mconvertview.findviewbyid(r.id.adview);           madview.loadad(adutils.getadmobrequestforcurrentuser()); 

so did wrong here when load failed google ads not showing?

you might try way:

  private adrequest adrequest;    adrequest = new adrequest.builder().build();    imbanner banneradview = (imbanner)mconvertview.findviewbyid(r.id.bannerview);   adview madview = (adview) mconvertview.findviewbyid(r.id.adview);   adrequest = new adrequest.builder().build();   adutils.getinstance().loadinmobibanner(banneradview, new iadlistener() {     @override     public void onfail() {         madview.loadad(adrequest);     }   }); 

Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -