java - Strange Problem with Android, Program compiles but does not work -


in android project, have simple java file gets webpage content, text , returns text string. text display in scrollview in activity on android.

it works fine, problem comes when try manipulating text in java file. tried arrays, didn't work switched string, still nothing. particular method fails provide output program compiles fine.

however, same method when tried in java project in eclipse works fine.

here's code:

// method return selected stripped text extracted rawdata public static string fillmenus(string rawdata){     string result = "";     int c1, c2;     for(int i=0; i<11; i++){          c1 = rawdata.indexof("\" width=\"50px\" />") + 17;         c2 = rawdata.indexof(" €</td>") + 2;          if (c1==16 || c2==1) break;         if (c1<=c2){             result = result+"\n"+ rawdata.substring(c1, c2);              rawdata = rawdata.substring(c2);         }         if (c1>c2){              result = result+"\n"+striptag((rawdata.substring(0, c2)));              rawdata = rawdata.substring(c2);         }     }      return result; } 

if there nothing wrong method, why not provide output? if return rawdata in android, phone displays properly. if return output result string, blank in phone.

if call method (say created in class abc) in test class (test.java) inside same android project string = abc.fillmenus(string b) there strange. compiler error, while shows blank in android phone. , same thing called within java project works absolutely fine.

is there i'm missing?

a few things

1) loop ?

2) if (c1<=c2) , if (c1>c2) exclusive recommend change if (c1>c2) else (helps in future when want change code)

3) should init result null more "", test @ exit of fillmenu know when code skipped or when there no values.

now guess reason if (c1==16 || c2==1) break; triggered , therefore resultt never changed hence exists empty.

you should run code in debug , put break point in it, monitor particularly values of c1 c2

a part form don't think there enough info more

jason


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -