-2

I got this code

public void displayText(){
    int resourceId = getResources().getIdentifier(chosenArrayName, "array", getPackageName());
    String[] array = getResources().getStringArray(resourceId);
    int arraySize = array.size();
    for(int i = 0; i < arraySize; i++) {
        textView.append(array[i]);}

    }

From Android how to print a array in text view or anything

The arraySize = array.size(); cannot be resolved. Anyone help me to point out why?

Anthony
  • 51
  • 7

1 Answers1

-1

You cannot call size() method in int. Try this :

public void displayText(){
    int resourceId = getResources().getIdentifier(chosenArrayName, "array", getPackageName());
    String[] array = getResources().getStringArray(resourceId);
    int arraySize = array.length;
    for(int i = 0; i < arraySize; i++) {
        textView.append(array[i]);}
}
Thomas Mary
  • 1,406
  • 1
  • 12
  • 23