Android Studio - Using XML id in the java code



Here is the thing guys, I have this line of code


adapter = ArrayAdapter.createFromResource(this,R.array.cars10, R.layout.teste); where cars10 is an string array, but what happens is that I have 10 string arrays: cars1,cars2,cars3...and so on...


I'd like to know if I can do it in an easy way, for example



for(int i=1;i<=10;i++)adapter[i] = ArrayAdapter.createFromResource(this,R.array.cars+"i", R.layout.teste);``


ps: I know it does not work, it's so you guys can understand what I mean.


Thank you very much


No comments:

Post a Comment