Android ListView data is not repeating -



Android ListView data is not repeating -

i trying show info in listview .but showing info lastly position. here code:

public class listdetailsactivity extends activity { /** called when activity first created. */ private context con; private string pos = ""; private imageview cphoto; private textview cname, aname, atext; private cacheimagedownloader downloader; private bitmap defaultbit; private progressdialog pdialog; private citydetailslist cd; private listview clist; private hotelmenuadapter madapter; private string response = ""; @override protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); requestwindowfeature(window.feature_no_title); setcontentview(r.layout.detailslayout); con = this; initui(); } private void initui() { // todo auto-generated method stub cname = (textview) findviewbyid(r.id.cname); clist = (listview) findviewbyid(r.id.cdetailsview); aname = (textview) findviewbyid(r.id.authorname); atext = (textview) findviewbyid(r.id.authortext); cphoto = (imageview) findviewbyid(r.id.cphoto); downloader = new cacheimagedownloader(); defaultbit = bitmapfactory.decoderesource(getresources(), r.drawable.attractionpng); // pos = getintent().getstringextra("id"); printlog.mylog("citydetails :", pos + "main"); updateui(); } private void updateui() { if (!sharedpreferenceshelper.isonline(con)) { alertmessage.showmessage(con, "error", "no net connection"); return; } pdialog = progressdialog.show(this, "please wait...", "loading...", false, false); final thread d = new thread(new runnable() { public void run() { // todo auto-generated method stub seek { if (allcitydetailsparser.connect(con, allurl .cityguidedetailsurl())) { } } grab (final exception e) { // todo: handle exception e.printstacktrace(); } seek { if (citydetailsparser.connect(con, allurl .cityguidedetailsurl())) { } } grab (final exception e) { // todo: handle exception e.printstacktrace(); } runonuithread(new runnable() { public void run() { // todo auto-generated method stub if (pdialog != null) { pdialog.cancel(); } seek { cd = allcitydetails.getallcitydetails() .elementat(0); cname.settext(cd.getname().trim()); seek { if (cd.geticon().length() != 0) { downloader.download(cd.geticon().trim(), cphoto); allconstants.cphotolink = cd.geticon() .replaceall(" ", "%20"); } else { cphoto.setimagebitmap(defaultbit); allconstants.cphotolink = cd.geticon(); } } grab (exception e) { // todo: handle exception } if (allcitydetails.getallcitydetails().size() != 0) { madapter = new hotelmenuadapter(con); clist.setadapter(madapter); printlog.mylog("i in list adapter : ", "true"); } } grab (exception e) { // todo: handle exception } } }); } }); d.start(); } class hotelmenuadapter extends arrayadapter<citydetailslist> { private final context con; public hotelmenuadapter(context context) { super(context, r.layout.rowdetails, allcitydetails .getallcitydetails()); con = context; // todo auto-generated constructor stub } @override public view getview(final int position, view convertview, viewgroup parent) { view v = convertview; if (v == null) { final layoutinflater vi = (layoutinflater) con .getsystemservice(context.layout_inflater_service); v = vi.inflate(r.layout.rowdetails, null); } if (position < allcitydetails.getallcitydetails().size()) { final citydetailslist r = allcitydetails .getcitydetailslist(position); final textview aname = (textview) v .findviewbyid(r.id.authorname); aname.settext(r.getauthor_name().trim()); final textview atext = (textview) v .findviewbyid(r.id.authortext); atext.settext(r.gettext().trim()); printlog.mylog("authorname : ", r.getauthor_name() + "!!!"); } // todo auto-generated method stub homecoming v; } } }

use code way first :

final myprogressdialog progdailog = new myprogressdialog( getactivity()); final handler handler = new handler() { @override public void handlemessage(message msg) { //set listview adapter here } }; new thread() { public void run() { seek { // set calling method here.. } grab (exception e) { // todo: handle exception log.e("error", "" + e.getmessage().tostring()); } handler.sendemptymessage(0); progdailog.dismiss(); } }.start();

in adapter there many problem.. please seek way..

clickhere clickhere

android android-listview position

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -