3

So i have an array of Integers "images_array" stored in strings.xml. I am trying to extract it into my Websites.java file to use it to display images.

But i get this error for some reason:

enter image description here

I tried storing the array in the same file as the one that is calling it, and it works, its just that, calling it from strings.xml is not working for me. maybe there is something i didnt learn yet?

Would really appreciate any help.

Thanks!

tynn
  • 38,113
  • 8
  • 108
  • 143
Abz Manakibwala
  • 129
  • 1
  • 10
  • http://stackoverflow.com/questions/4444950/loading-integer-array-from-xml – Anik Islam Abhi Oct 01 '16 at 16:58
  • You should consider asking another question instead of changing the one you've asked before. The link before should answer this one though. And don't use `R.drawable.pic2` in XML – tynn Oct 01 '16 at 17:18
  • I am sorry, i am new to SO. I will ask this as a new question. Btw,thanks a lot for your help :) – Abz Manakibwala Oct 01 '16 at 17:22

2 Answers2

6

Integer and int can be used interchangeably, because the compiler wraps and unwraps these automatically.

This doesn't count for arrays. Integer[] and int[] are two totally different types. getIntArray() returns int[], so you cannot declare images as Integer[] or have to copy the items manually. But better don't even use Integer if not necessary.

int[] images;
tynn
  • 38,113
  • 8
  • 108
  • 143
1

Change the data type of 'images' from "Integer[]" to "int[]"

yudori
  • 78
  • 1
  • 2
  • 10