Define a method which will convert all String value of arraylist
into integer.
private ArrayList getIntegerArray(ArrayList stringArray) {
ArrayList result = new ArrayList();
for(String stringValue : stringArray) {
try {
//Convert String to Integer, and store it into integer array list.
result.add(Integer.parseInt(stringValue));
} catch(NumberFormatException nfe) {
//System.out.println("Could not parse " + nfe);
Log.w("NumberFormat", "Parsing failed! " + stringValue + " can not be an integer");
}
}
return result;
}
And simply call that method, as
ArrayList resultList = getIntegerArray(strArrayList); //strArrayList is a collection of Strings as you defined.
Happy coding :)