java - Error:(136, 81) error: incompatible types: String cannot be converted to int -


i'm wanted show progress bar in listview. below code part of mycustombaseadapter.

public class mycustombaseadapter extends baseadapter{   // listview       private static arraylist<searchresults> searcharraylist;     relativelayout footerlayout;     private layoutinflater minflater;     listview listview;       public mycustombaseadapter(context context, arraylist<searchresults> results,listview listview,relativelayout footerlayout) {         searcharraylist = results;         this.listview=listview;         this.footerlayout=footerlayout;         minflater = layoutinflater.from(context);         addorremovefooter();     }      public view getview(int position, view convertview, viewgroup parent) {         final searchresults search=getitem(position);         viewholder holder;         if (convertview == null) {             convertview = minflater.inflate(r.layout.custom_row_view, null);             holder = new viewholder();             holder.txtproject= (textview) convertview.findviewbyid(r.id.listproject);             holder.txtdescription = (textview) convertview.findviewbyid(r.id.listdescription);             //holder.txtprogress = (textview) convertview.findviewbyid(r.id.listprogress);             holder.progressbar=(progressbar)convertview.findviewbyid(r.id.downloadprogressbar);             holder.txtin=(textview)convertview.findviewbyid(r.id.listtimein);             holder.txtout=(textview)convertview.findviewbyid(r.id.listtimeout);             holder.search = search;              convertview.settag(holder);         } else {             holder = (viewholder) convertview.gettag();         }          holder.txtproject.settext(searcharraylist.get(position).getproject());         holder.txtdescription.settext(searcharraylist.get(position).getdescription());         //holder.txtprogress.settext(searcharraylist.get(position).getprogress());         holder.txtin.settext(searcharraylist.get(position).gettimein());         holder.txtout.settext(searcharraylist.get(position).gettimeout());         holder.progressbar.setprogress(searcharraylist.get(position).getprogress()); // error on line setprogress(int) cannot applied java.lang.string         return convertview;     }      static class viewholder {         textview txtproject;         textview txtdescription;         textview txtin;         textview txtout;         progressbar progressbar;         searchresults search;      } } 

searchresults

 private string progress="";    public void setprogress(string progress){         this.progress=progress;     }      public string getprogress()     {         return progress;     } 

i'm getting erorr because setprogress require int have string datatype in get , setprogress. there away can use solve error line without changing datatype in searchresults?

how can apply this line holder.progressbar.setprogress(searcharraylist.get(position).getprogress());

you use integer.parseint(string) like,

holder.progressbar.setprogress(     integer.parseint(searcharraylist.get(position).getprogress())); 

parse value

based on comment below, split string , take integral part. like,

string str = searcharraylist.get(position).getprogress(); string[] arr = str.split(":\\s*"); holder.progressbar.setprogress(integer.parseint(arr[1])); 

Comments

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -