android - getview() method of baseadapter not called in fragment -
i using fragment display list. listadapter uses baseadapter. returns getcount greater 0 still not called getview() method.
also set adapter in fragment , called listadapter :
mlistadapter = new mylistadapter(getactivity(), data, enum); slist.setadapter(mlistadapter); mlistadapter.notifydatasetchanged();
adapter gets called without problem , getcount()
called getview()
doesn't called.
listadapter :
public class mylistadapter extends baseadapter { private arraylist<watchvo> data; private static layoutinflater inflater; private context mcontext; private enum enum; public string tag = "mylistadapter"; public mylistadapter(context context, arraylist<watchvo> data, enum enum) { // super(context,0,data); this.mcontext = context; this.data = data; this.enum = enum; inflater = (layoutinflater) mcontext.getsystemservice(context.layout_inflater_service); } @override public int getcount() { log.d(tag,"count"+data.size()); if (data.size()<=0) return 1; return data.size(); } @override public object getitem(int position) { log.d(tag,"getitem"+data.get(position)); return data.get(position); } @override public long getitemid(int position) { return position; } @suppresslint("newapi") @override public view getview(int position, view convertview, viewgroup parent) { final viewholder holder; if(convertview==null) { holder = new viewholder(); log.d(tag,""+parent +"pos" + position); convertview = inflater.inflate(r.layout.single_row_scripts,parent,false); holder.tablerow = (tablerow) convertview.findviewbyid(r.id.table_row_item); holder.pricechangecontainer = (linearlayout) convertview.findviewbyid(r.id.color_container_red_green); holder.sname = (textview) convertview.findviewbyid(r.id.sname); holder.sprice = (textview) convertview.findviewbyid(r.id.smrp); holder.spricechange = (textview) convertview.findviewbyid(r.id.sprice); holder.spricepercentagechange = (textview) convertview.findviewbyid(r.id.spricechange); holder.svolume = (textview) convertview.findviewbyid(r.id.svolume); holder.sname.settext(data.get(position).getsname()); holder.sprice.settext(data.get(position).getsmrp()); holder.spricechange.settext(data.get(position).getschange()); holder.spricepercentagechange.settext(data.get(position).getspercentagechange()); convertview.settag(holder); } else { holder = (viewholder) convertview.gettag(); } return convertview; } public static class viewholder { public textview sname, sprice, spricechange, spricepercentagechange, svolume; public linearlayout pricechangecontainer; public tablerow tablerow; } }
your passing wrong adapter listview. change code
mlistadapter = new mylistadapter(getactivity(), data, enum); slist.setadapter(marketmoverslistadapter); mlistadapter.notifydatasetchanged();
to
mlistadapter = new mylistadapter(getactivity(), data, enum); slist.setadapter(mlistadapter); mlistadapter.notifydatasetchanged();
Comments
Post a Comment