android - listview not updated baseadapter -
android - listview not updated baseadapter -
i working baseadapter. have 2 datetimeformat 09/01/2014 , 09/10/2014.i checked days between there datetimes
public string getdatediffstring(date dateone, date datetwo) { long timeone = dateone.gettime(); long timetwo = datetwo.gettime(); long oneday = 1000 * 60 * 60 * 24; long delta = (timetwo - timeone) / oneday; if (delta > 0) { (int = 0; < delta; i++) { } homecoming string.valueof(delta) ; } else { delta *= -1; homecoming string.valueof(delta); } }
and wrote funtciton alter there datetimes format 09/01/2014 changed 1 sep
public static string dateformatterforlukka(string inputdate,int lenght) { string inputformat = "mm/dd/yyyy"; string outputformat = string.valueof(lenght)+"mmm"; date parsed = null; string outputdate = ""; seek { simpledateformat df_input = new simpledateformat(inputformat, new locale("en", "us")); simpledateformat df_output = new simpledateformat(outputformat, new locale("en", "us")); parsed = df_input.parse(inputdate); outputdate = df_output.format(parsed); log.wtf("outputdate", outputdate); } grab (exception e) { outputdate = inputdate; } homecoming outputdate; }
now want add together datetimes in listview .betweeen days there 2 datetimes . 1 sep,2 sep etc...
baseadapter code
public class holladapters extends baseadapter { private context mcontext; private final arraylist<cinemainfomodel> hollitems; private cinemainfomodel objbean; private textview start_time,holle,time; private static layoutinflater inflater = null; public holladapters(context context, arraylist<cinemainfomodel> hollitems) { mcontext = context; this.hollitems = hollitems; inflater = (layoutinflater) mcontext .getsystemservice(context.layout_inflater_service); } @override public int getcount() { homecoming hollitems.size(); } @override public object getitem(int position) { homecoming null; } @override public long getitemid(int position) { homecoming 0; } @suppresslint("viewholder") @override public view getview(int position, view convertview, viewgroup parent) { view grid; grid = new view(mcontext); grid = inflater.inflate(r.layout.cinema_holl_adapter, null); start_time = (textview) grid.findviewbyid(r.id.adapter_day); holle = (textview) grid.findviewbyid(r.id.adapter_holl); time = (textview) grid.findviewbyid(r.id.adapter_time); objbean = hollitems.get(position); start_time.settext(objbean.getstarttime()); holle.settext(objbean.gethole()); string start_time=objbean.gettime(); start_time=start_time.replace(",", "\n"); time.settext(start_time); homecoming grid; }
}
this main java code
simpledateformat df = new simpledateformat( "mm/dd/yyyy"); date _d = df.parse("09/01/2014"); date _d1 = df.parse("09/10/2014"); simpledateformat new_df = new simpledateformat( "d mmm"); string _s1 = new_df.format(_d1); string datetimeis=getdatediffstring(_d1, _d); log.wtf("differentis ", datetimeis); int abc=integer.parseint(datetimeis); (int l = 0; l < abc; l++) { string ab = dateformatterforlukka(timejsonarray .getjsonobject(k).getstring("start_time"),l++); log.wtf("timeeeeeeeee", ab); cinematime.setstarttime(ab); cinematime.setendtime(_s1); cinematimesarray.add(cinematime); }
when run app 8 sep added in listview ,but loged , in log have different result, meybe listview did not updated
what doing wrong? if knows solution please help me
create methord in adapter class
public void setdata(arraylist<cinemainfomodel> hollitems_temp) { this.hollitems=hollitems_temp; }
for (int l = 0; l < abc; l++) { string ab = dateformatterforlukka(timejsonarray .getjsonobject(k).getstring("start_time"),l++); log.wtf("timeeeeeeeee", ab); cinematime.setstarttime(ab); cinematime.setendtime(_s1); cinematimesarray.add(cinematime); }
after loop assuming cinematimesarray of type cinemainfomodel
youradapter.setdata(cinematimesarray); youradapter.notifydatasetchanged();
put debugger in getview methord , check;
android listview baseadapter datetime-format
Comments
Post a Comment