android - RecyclerView is not populated with array list of objects -


i'm fetching images api , i'm loading images imageview using glide library, happening. images loaded , stored values in array of objects, somehow array isn't attached adapter of recyclerview. have tried many combination, putting initialization of recyclerview behind block of code i'm adding items array , updating adapter using method notifydatasetchanged() , didn't give me result. have tried put initialization of recyclerview , adapter after adding items, still no effects. here code:

onactionlistener<list<like>> onlikelistener = new onactionlistener<list<like>>() {     @override     public void oncomplete(list<like> likes) {         musers.clear();          (like : likes) {             user user = new user();             user.setuserid(like.getuser().getid());             musers.add(user);         }          configurerecyclerview();     } }; 

and inside method configurerecyclerview():

private void configurerecyclerview() {     userrecyler = (recyclerview) findviewbyid(r.id.list);     userrecyler.sethasfixedsize(true);      linearlayoutmanager horizontallayoutmanager =             new linearlayoutmanager(homeactivity.this, linearlayoutmanager.horizontal, false);     userrecyler.setlayoutmanager(horizontallayoutmanager);     userrecyler.setitemanimator(new defaultitemanimator());      madapter    = new userlistadapter(homeactivity.this, musers);     userrecyler.setadapter(madapter); } 

added adapter class question(update)

public class userlistadapter extends recyclerview.adapter<userlistadapter.userviewholder> {  private list<user> musers; private context mcontext;  public userlistadapter(context context, list<user> users) {     mcontext = context;     musers   = users; }   @override public userviewholder oncreateviewholder(viewgroup parent, int viewtype) {     view view = layoutinflater.from(mcontext).inflate(r.layout.user_lst_item, parent, false);      return new userviewholder(view); }  @override public void onbindviewholder(userviewholder holder, int position) {     user user = musers.get(position);      glide.with(mcontext)             .load("http://graph.facebook.com/" + user.getuserid() + "/picture?width=150&height=150")             .fitcenter()             .placeholder(r.drawable.ic_ikonica_t)             .diskcachestrategy(diskcachestrategy.source)             .into(holder.userprofilepic); }  @override public int getitemcount() {     return musers == null ? 0 : musers.size(); }  public class userviewholder extends recyclerview.viewholder {     circularimageview userprofilepic;      public userviewholder(view itemview) {         super(itemview);         userprofilepic = (circularimageview) itemview.findviewbyid(r.id.iv_user_image);     } } } 

now, every recyclerview list attached 1 fragment of view pager, , happening when swipe , come same fragment. images being loaded cache memory. images loading , values stored in array list, there problem recyclerview. can me this?

warning: i've joined site, think know answer here. please let me know if helps.

edit: can try using youradapter.notifydatasetchanged() @ end of first method gets images.

are setting images inside adapters onbindviewholder method? setup few adapters recyclerviews , found best place it. seem passing in array file, need set inside recycler view.

in constructor pass in json file , save adapter, used in onbindviewholder.

  public adapter_tastings(jsonobject _tastingsjson, context context){     mcontext = context;     try{         tastingskey = _tastingsjson.getjsonarray("key");         tastingsjson = _tastingsjson.getjsonobject("tastings");     } catch(jsonexception e){         e.printstacktrace();     } } 

i use values in file set, below. viewholder class that's declared within adapter holds actual references views inside recyclerview item layout.

@override public void onbindviewholder(adapter_tastings.viewholder viewholder, int position){     textview mtastingdate = viewholder.tastingdate;     textview mtastingtime = viewholder.tastingtime;     textview mtastinglocation = viewholder.tastinglocation;     textview mtastingphone = viewholder.tastingphone;      try {         string key = tastingskey.getstring(position);          mtastingdate.settext(tastingsjson.getjsonobject(key).getstring("date"));         mtastinglocation.settext(tastingsjson.getjsonobject(key).getstring("location"));         mtastingtime.settext(tastingsjson.getjsonobject(key).getstring("time"));         mtastingphone.settext(tastingsjson.getjsonobject(key).getstring("phone"));     } catch(jsonexception e){         e.printstacktrace();     } } 

Comments