Hi I'm not sure if this is a problem with Eclipse or Java but recently my code has stopped working. I only changed things like assigning new variables to store things. My program takes a multi-dimensional string array and should return a new array trimmed of nulls.
public void makebuttons(final int n, String equals) {
//does lots of widget functions and id assignments
String[] items=getArray(Integer.parseInt(data.equnits.substring(n*3, n*3+1)));
unitvalues[n]=Integer.parseInt(data.equnits.substring(n*3, n*3+1));
ArrayAdapter aa = new ArrayAdapter(this,android.R.layout.simple_spinner_item, items);
//does more code
}
public static String[] getArray(int selection) {
String[] result;//stores the new array
int x=0,j=0 ,ulength = data.units[0].length;//ints used
String temp="";
while(j < ulength && temp!=null) {
temp= data.units[selection][j][0]; //find the actual array length
j++;
}
if(j==ulength)j--;
result = new String[j+1];//initalise array from check
for(x=0; x<=j; x++) { //add data to array
result[x]=data.units[selection][x][0];
}
return result;//return corrected array
}
Integer.parseInt
and Integer.valueOf
give value of 0 each time for a string like "01,02,03,04" data.equnits
stores the string to be converted to integer by checking 2 digits only to select from a large 3 dimensional array. Since its a 3 dimensional array some nulls are present
Null check for the String doesnt seem to work since the while loop doesnt seem to detect it and it ends up being in the array that gets passed into the array adapter for spinner causing NullPointerException
while scrolling.
Restarting eclipse doesn't help.