android - stub_image showing on universal image loader in recyclerview -


i have implement universal image loader showing images in recyclerview. showing stub_image. code contain 1 fragment , adapter, working before added universal-image-loader.

here code:

fragment.class

public class fourthfragment extends fragment {     private displayimageoptions options;     imageloader imageloader;     recyclerview rv;     recyclerview.layoutmanager mlayoutmanager;     recyclerview.adapter madapter;     string[] str = {"one","two","three","four"};     int[] img = {r.mipmap.rio_one,r.mipmap.rio_two,r.mipmap.rio_three,r.mipmap.rio_four};      @override     public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) {         view v = inflater.inflate(r.layout.view_pager_fourth_fragment, container, false);          try {             rv = (recyclerview) v.findviewbyid(r.id.recycler_view);             rv.sethasfixedsize(true);             mlayoutmanager = new linearlayoutmanager(getcontext());             rv.setlayoutmanager(mlayoutmanager);          } catch (exception e) {             e.printstacktrace();             log.e("some error", "" + e);         }          madapter = new recyclerview_adapter(getactivity(), r.layout.view_pager_card_view,str,img);         rv.setadapter(madapter);          return v;     } 

recyclerviewadapter.class

private class recyclerview_adapter extends recyclerview.adapter<recyclerview_adapter.dataholder> {     string [] result;     activity activity;     int layoutresourceid;     int[] imgs;      public recyclerview_adapter(fragmentactivity activity, int layoutresourceid, string [] result, int[] img) {         this.layoutresourceid=layoutresourceid;         this.activity=activity;         this.result=result;         this.imgs=img;     }      public class dataholder extends recyclerview.viewholder{         protected textview tv1;         protected imageview iv1;         public dataholder(view v){             super(v);              tv1=(textview)v.findviewbyid(r.id.textview1);             iv1=(imageview)v.findviewbyid(r.id.icon);          }     }      @override     public dataholder oncreateviewholder(viewgroup v, int i) {         view item = layoutinflater.from(v.getcontext()).inflate(r.layout.view_pager_card_view, v, false);         return new dataholder(item);     }      @override     public void onbindviewholder(dataholder holder, int position) {          imageloaderconfiguration configbuilder = new imageloaderconfiguration.builder(getcontext())                 .threadpriority(thread.norm_priority - 2)                 .denycacheimagemultiplesizesinmemory()                 .build();          imageloader = imageloader.getinstance();         imageloader.init(configbuilder);         options = new displayimageoptions.builder()                 .showstubimage(r.mipmap.stub_image) // stub_image showing                 .showimageforemptyuri(r.mipmap.image_for_empty_url)                 .cacheinmemory(true)                 .cacheondisc(true)                 .build();          holder.tv1.settext(result[position]);         imageloader.displayimage("mipmap://" + imgs[position], holder.iv1, options);     }      @override     public int getitemcount() {         log.e("list size", "" + result.length);         return imgs.length;     }  } 

it’s best practice place app icons in mipmap- folders (not drawable- folders) because used @ resolutions different device’s current density.

referenced google blogpost article.

mipmap folder's app icons (ic_launcher.png) , other drawable files (like selectors, shape drawables, other icons etc) should put in respective drawable folder's.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -