listview - How to add the text at the particular position in custom adapter in android -
i creating android app populates list of gps co-ordinates entered user using custom adapter
selection lat long distance ------------------------------------------------- checkbox1 123.4546 456.48751 text checkbox2 123.4546 456.48751 text checkbox3 123.4546 456.48751 text checkbox4 123.4546 456.48751 text
if user selects check-box 1 have find distance check-box 1 lat long check-box 2,check-box 3,check-box-4 lat long .here need display result text in field of text
respective position here getting result @ last position can tell me how achieve fyi:[![enter image description here][2]][2] sc explain in detail. if check 1 value updating result @ last value need update , display result whole data code
check_locations.setoncheckedchangelistener(new compoundbutton.oncheckedchangelistener() { @override public void oncheckedchanged(compoundbutton buttonview, boolean ischecked) { if (ischecked) { latitude_string = location.getlatitude(); longitude_string = location.getlongitude(); baselat_double = double.parsedouble(latitude_string); baselong_double = double.parsedouble(longitude_string); location_a = new location("base position"); location_a.setlatitude(double.parsedouble(latitude_string)); location_a.setlongitude(double.parsedouble(longitude_string)); location_b = new location("end position"); (int = 0; < objects.size(); i++) { finallat_double = double.parsedouble(objects.get(i).getlatitude()); finallong_double = double.parsedouble(objects.get(i).getlongitude()); location_b.setlatitude(finallat_double); location_b.setlongitude(finallong_double); distance = location_a.distanceto(location_b); distance = distance * 1.609344; objects.get(i).setdistance(string.valueof(distance)); } notifydatasetchanged(); distance_text.settext(location.getdistance()); } } }); return locations_row; }
modify getview()
methods this
@override public view getview(final int position, view convertview, final viewgroup parent) { final view locations_row = layoutinflater.from(context).inflate(r.layout.layout_adapter_list_details, null); final locations_modle location = (locations_modle) objects.get(position); textview text_cust_name = (textview) locations_row.findviewbyid(r.id.txt_cust_name_heading); textview latitude = (textview) locations_row.findviewbyid(r.id.txt_latitude); latitude.settext(location.getlatitude()); textview longitude = (textview) locations_row.findviewbyid(r.id.txt_longitude); textview distance_text = (textview) locations_row.findviewbyid(r.id.txt_distance); if (stringutils.isempty(location.getdistance())) distance_text.settext("distance"); longitude.settext(location.getlongitude()); text_cust_name.settext(location.getlocationname()); checkbox check_locations = (checkbox) locations_row.findviewbyid(r.id.check_locations); check_locations.settag(position); if (position == selectedpostion) { check_locations.setchecked(true); } else { check_locations.setchecked(false); } check_locations.setoncheckedchangelistener(new compoundbutton.oncheckedchangelistener() { @override public void oncheckedchanged(compoundbutton buttonview, boolean ischecked) { if (ischecked) { selectedpostion = (int) buttonview.gettag(); latitude_string = objects.get(selectedpostion).getlatitude(); longitude_string = objects.get(selectedpostion).getlongitude(); baselat_double = double.parsedouble(latitude_string); baselong_double = double.parsedouble(longitude_string); location_a = new location("base position"); location_a.setlatitude(double.parsedouble(latitude_string)); location_a.setlongitude(double.parsedouble(longitude_string)); location_b = new location("end position"); (int = 0; < objects.size(); i++) { finallat_double = double.parsedouble(objects.get(i).getlatitude()); finallong_double = double.parsedouble(objects.get(i).getlongitude()); location_b.setlatitude(finallat_double); location_b.setlongitude(finallong_double); distance = location_a.distanceto(location_b); distance = distance * 1.609344; objects.get(i).setdistance(distance); } locations_adapter.this.notifydatasetchanged(); } } }); return locations_row; }
Comments
Post a Comment