android - textview separated in each row of listview -


i have 7 textview represents date ex. august 1,august 2,august 3...this 7 textview showed in each row of listview,the problem when click button textview showed in last item of listview.

this im trying achieve http://img818.imageshack.us/img818/416/q39d.png

listitem0

august 1

listitem1

august 2

....

here code in getview

public view getview(int position, view convertview, viewgroup parent) {      //august1     calendar mcalendar = new gregoriancalendar();     mcalendar.set(calendar.day_of_week, calendar.monday);     simpledateformat mdf = new simpledateformat("dd mmmm");     string fdate = mdf.format(mcalendar.gettime());     //august2     mcalendar.add(calendar.day_of_month, 1);     string secdate = mdf.format(mcalendar.gettime());      mcalendar.add(calendar.day_of_month, 1);     string tdate = mdf.format(mcalendar.gettime());      mcalendar.add(calendar.day_of_month, 1);     string fourthdate = mdf.format(mcalendar.gettime());      layoutinflater inflater = (layoutinflater) context             .getsystemservice(context.layout_inflater_service);     view rowview = inflater.inflate(r.layout.activity_main, parent, false);     fday = (textview) rowview.findviewbyid(r.id.fdate);     secday = (textview) rowview.findviewbyid(r.id.secdate);     tday = (textview) rowview.findviewbyid(r.id.tdate);     fourthday = (textview) rowview.findviewbyid(r.id.fourthdate);        button test = (button) rowview.findviewbyid(r.id.btn);      test.setonclicklistener(new onclicklistener() {         //to increment date         @override         public void onclick(view v) {             // todo auto-generated method stub             weeknumber = weeknumber + 1;             fday.settext(getnextweek(weeknumber));          }      });      fday.settext(values[position]);     //text.settext(values[position]);      // change icon based on name     string s = values[position];     //string bs = values[position];      system.out.println(s); //system.out.println(bs);      //represent date in row     //listitem0     if (s.equals("date 1")) {         fday.settext(fdate);     //listitem1     } else if (s.equals("date 2")) {     secday.settext(secdate);     //listitem2     } else if (s.equals("date 3")) {     tday.settext(tdate);      } else if (s.equals("date 4")) {         fourthday.settext(fourthdate);       ......       } else {          // textview.settext(fdate);     }      return rowview; }  // method adjust date private static string getnextweek(int weekfromtoday) {     calendar mcalendar = new gregoriancalendar();     mcalendar.set(calendar.day_of_week, calendar.monday);     mcalendar.set(calendar.week_of_year,             mcalendar.get(calendar.week_of_year) + weekfromtoday);      simpledateformat mdf = new simpledateformat("dd mmmm");     string fdate = mdf.format(mcalendar.gettime());     fday.settext(fdate);      mcalendar.add(calendar.day_of_month, 1);     string secdate = mdf.format(mcalendar.gettime());     mcalendar.add(calendar.day_of_month, 1);     string tdate = mdf.format(mcalendar.gettime());     mcalendar.add(calendar.day_of_month, 1);     string fourthdate = mdf.format(mcalendar.gettime());      fday.settext(fdate);     secday.settext(secdate);     tday.settext(tdate);     fourthday.settext(fourthdate);      return fdate;  } 

}

that more accurate way implement getview method reusing of list views:

public view getview(int position, view convertview, viewgroup parent) {   view view = null;   if (convertview == null) {     layoutinflater inflater = context.getlayoutinflater();     view = inflater.inflate(textviewresourceid, parent, false);    } else {     view = convertview;   }    return view; } 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -