android - RelativeLayout is always adding under one recyclerview item -


please have on image below :

enter image description here

this recyclerview in every item contains recyclerview (white space under "hp").

now problem no matter on arrow click adding recyclerview under "hp" only. need me added under item on click.

first fragment (containing first recyclerview)

public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) {          final view intent = inflater.inflate(r.layout.fragment_brand, container, false);         //bundle object send data fragment         bundle = new bundle();         brandfragmentgrid = intent.findviewbyid(r.id.fragment_grid);          progressbar = intent.findviewbyid(r.id.brand_progressbar);         progressbar.setvisibility(view.visible);         final string selectedproductid = getarguments().getstring(appconstants.selected_product);         if (selectedproductid != null) {             //server api call brand fragment             getproductdetailsbyproductid(selectedproductid);         }          brandfragmentgrid.setonitemclicklistener(new adapterview.onitemclicklistener() {             @override             public void onitemclick(adapterview<?> adapterview, view view, int i, long l) {                 string seletedserviceid = adapterview.getitematposition(i).tostring();                 bundle.putstring(appconstants.selected_service, seletedserviceid);             }         });          return intent;     }      private void getproductdetailsbyproductid(string selectedproductid) {         final arraylist<brandbean> brandbeanarraylist = new arraylist<>();         final jsonarrayrequest jsonarrayrequest = new jsonarrayrequest(                 request.method.get,                 apiendpoints.geturi(selectedproductid),                 null,                 new response.listener<jsonarray>() {                     @override                     public void onresponse(jsonarray response) {                         if (response.length() > 0) {                             (int = 0; < response.length(); i++) {                                 try {                                     brandbeanarraylist.add(databaseobjectsmapper.brandbeanmapper((jsonobject) response.get(i)));                                 } catch (jsonexception e) {                                     toast.maketext(getcontext(), "response parsing exception, contact admin", toast.length_short).show();                                 }                             }                             brandfragmentgrid.setadapter(new brandadapter(getcontext(), brandbeanarraylist));                             progressbar.setvisibility(view.invisible);                         } else {                             progressbar.setvisibility(view.invisible);                             toast.maketext(getcontext(), "no data in response", toast.length_short).show();                         }                     }                 },                 new response.errorlistener() {                     @override                     public void onerrorresponse(volleyerror error) {                         progressbar.setvisibility(view.invisible);                         toast.maketext(getcontext(), "server connection problem, try again.", toast.length_short).show();                     }                 });          volleysingleton.getinstance(getcontext()).addtorequestqueue(jsonarrayrequest);     } } 

first fragment adaper

public class brandadapter extends baseadapter {      private layoutinflater layoutinflater;     private context context;     private arraylist<brandbean> brandlist;       public brandadapter(final context context, final arraylist<brandbean> brandlist) {         this.context = context;         this.brandlist = brandlist;     }      @override     public int getcount() {         return brandlist.size();     }      @override     public object getitem(int i) {         return brandlist.get(i).getid();     }      @override     public long getitemid(int i) {         return 0;     }      @override     public view getview(final int i, view view, viewgroup viewgroup) {         layoutinflater = (layoutinflater) context.getsystemservice(context.layout_inflater_service);         if (view == null) {             view = layoutinflater.inflate(r.layout.item_brand_service_grid, null);              //grid relativelayout             //final relativelayout gridrl = view.findviewbyid(r.id.brand_service_container);              //grid text             final textview gridtext = view.findviewbyid(r.id.brand_grid_text);             gridtext.settext(brandlist.get(i).getservicetype());              //grid arraw             final imageview gridarrow = view.findviewbyid(r.id.brand_grid_arrow);             gridarrow.setonclicklistener(new view.onclicklistener() {                 @override                 public void onclick(view view) {                     final bundle bundle = new bundle();                     bundle.putstring(appconstants.selected_service,brandlist.get(i).getid());                      final brandservicefragment servicefragment = new brandservicefragment();                     servicefragment.setarguments(bundle);                      fragmenttransaction fragmenttransaction = mainactivity.mainactivity.getsupportfragmentmanager().begintransaction();                     fragmenttransaction.addtobackstack(null);                     fragmenttransaction.replace(r.id.brand_service_container, servicefragment);                     fragmenttransaction.commit();                      toast.maketext(context,brandlist.get(i).getid(),toast.length_long).show();                 }             });         }         return view;     } } 

second fragment (containing list should me displayed in white space when click on arrow)

public class brandservicefragment extends fragment {      private recyclerview recyclerview;     private progressbar progressbar;      @override     public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) {          view intent = inflater.inflate(r.layout.fragment_brand_service, container, false);         recyclerview = intent.findviewbyid(r.id.recycler_view_container);         recyclerview.setlayoutmanager(new linearlayoutmanager(getcontext()));          progressbar = intent.findviewbyid(r.id.service_progressbar);         progressbar.setvisibility(view.visible);          final string selectedservicetype = getarguments().getstring(appconstants.selected_service);         //server api call         if (selectedservicetype != null) {             getproductdetailsbyproductid(selectedservicetype);         }         return intent;     }      private void getproductdetailsbyproductid(string selectedservicetype) {         ((appglobalcontent)getcontext().getapplicationcontext()).getservicetypelist().clear();         final jsonarrayrequest jsonarrayrequest = new jsonarrayrequest(                 request.method.get,                 apiendpoints.service_type_issue_uri + selectedservicetype,                 null,                 new response.listener<jsonarray>() {                     @override                     public void onresponse(jsonarray response) {                         if (response.length() > 0) {                             (int = 0; < response.length(); i++) {                                 try {                                     ((appglobalcontent) getactivity().getapplicationcontext()).addservicetypelist(databaseobjectsmapper.servicetypebeanmapper((jsonobject) response.get(i)));                                 } catch (jsonexception e) {                                     progressbar.setvisibility(view.invisible);                                 }                             }                             recyclerview.setadapter(new brandserviceadapter(getcontext(), ((appglobalcontent) getactivity().getapplicationcontext()).getservicetypelist()));                         } else {                             toast.maketext(getcontext(), "no data in response", toast.length_short).show();                         }                         progressbar.setvisibility(view.invisible);                     }                 },                 new response.errorlistener() {                     @override                     public void onerrorresponse(volleyerror error) {                         progressbar.setvisibility(view.invisible);                         toast.maketext(getcontext(), "server connection problem", toast.length_short).show();                     }                 });          volleysingleton.getinstance(getcontext()).addtorequestqueue(jsonarrayrequest);     }  } 

second fragment recyclerview adapter

public class brandserviceadapter extends recyclerview.adapter<recyclerview.viewholder> {      private context context;     private list<servicetypebean> servicetypelist;      public brandserviceadapter(final context context, final list<servicetypebean> servicetypelist) {         this.context = context;         this.servicetypelist = servicetypelist;     }      @override     public recyclerview.viewholder oncreateviewholder(viewgroup viewgroup, int viewtype) {         layoutinflater inflater = layoutinflater.from(context);         view row = inflater.inflate(r.layout.item_brand_service, viewgroup, false);         return (new item(row,context,servicetypelist));     }      @override     public void onbindviewholder(recyclerview.viewholder holder, int position) {         ((item) holder).brandservicename.settext(servicetypelist.get(position).getissue());         ((item) holder).brandserviceprice.settext(servicetypelist.get(position).getpricerange()+" onwards");     }      @override     public int getitemcount() {         return servicetypelist.size();     }      public static class item extends recyclerview.viewholder implements view.onclicklistener {          private textview brandservicename;         private textview brandserviceprice;         private list<servicetypebean> servicetypelist;         private context context;          public item(view itemview, context context, list<servicetypebean> servicetypelist ) {             super(itemview);              this.context = context;             this.servicetypelist = servicetypelist;              itemview.setonclicklistener(this);              brandservicename = itemview.findviewbyid(r.id.brand_service_item_text);             brandserviceprice = itemview.findviewbyid(r.id.brand_service_item_price);         }          @override         public void onclick(view view) {             int position = getadapterposition();             servicetypebean servicetypebean = this.servicetypelist.get(position);             intent intent = new intent(this.context, selectserviceactivity.class);             intent.putextra(appconstants.selected_service_type_id,servicetypebean.getservicetypeid());             this.context.startactivity(intent);         }     } } 


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -