java - ArrayList not working as expected in do..while loop -


i have following loop creates string fits in screen, creates page speak.

    (int = 0; < totalline; i++) {          temp = enterline(mtextview, texttobeshown, i);             full = full + temp;      } 

so after iteration done full holds 1 page.

what want create outer iteration allows me create more 1 page, amount of pages created isn't defined. iteration needs stop if there aren't more pages created.

i tried following code reason when calling page pages.get(1) gives out whole string not full / page. example if 3 strings have been added arraylist pages there 3 strings in arraylist same value.

with testing log, know first iteration working well, , full gives expected values meaning in first do iteration gives out expected values full second iteration etc..

    do{     (int = 0; < totalline; i++) {          temp = enterline(mtextview, texttobeshown, i);         if(temp.trim().length() == 0){             break;         }else{             full = full + temp;         }     }     pages.add(full); 

so question doing wrong arraylist , why isn't working i'm expecting.

edit

this enterline code: more log's used didn't feel need display them all.

public string enterline(textview mtextview, string textbeshown, int i){          string a;         int number = mtextview.getpaint().breaktext(texttobeshown, 0, texttobeshown.length(),true,mtextview.getwidth(), null);          if(texttobeshown.substring(number-1,number) != " "){             number = texttobeshown.substring(0,number).lastindexof(" ");             log.e("tag1", "found " + i);         }          = (texttobeshown.substring(0, number) + "\n");         log.e(tag, texttobeshown.substring(0, number));         texttobeshown = texttobeshown.substring(number, texttobeshown.length());         return a;     } 

do{     full=""     (int = 0; < totalline; i++) {         temp = enterline(mtextview, texttobeshown, i);         if(temp.trim().length() == 0){             break;         }else{             full = full + temp;         }     }     pages.add(full); }while(...) 

or better

do{     stringbuilder builder = new stringbuilder();     (int = 0; < totalline; i++) {         temp = enterline(mtextview, texttobeshown, i));         if(temp.trim().length() == 0){             break;         }else{             builder.append(temp);         }     }     pages.add(builder.tostring()); }while(...) 

Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -