Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how we can get the arraylist(both string and integer) from the resources xml

Tags:

android

Hi want to get the arraylist from the resources.xml is there any code for this.please give me some suggestions.Thanks in advance

like image 654
Pinki Avatar asked Mar 03 '11 09:03

Pinki


People also ask

How do you store a String and integer together in an ArrayList?

You can do this as follows but have to give up on generics for the list container. List<List> listOfMixedTypes = new ArrayList<List>(); ArrayList<String> listOfStrings = new ArrayList<String>(); ArrayList<Integer> listOfIntegers = new ArrayList<Integer>(); listOfMixedTypes. add(listOfStrings); listOfMixedTypes.


1 Answers

Use Arrays.asList :

String[] myResArray = getResources().getStringArray(R.array.my_array); List<String> myResArrayList = Arrays.asList(myResArray); 

This list will be immutable, so if you want a mutable list, just do :

List<String> myResMutableList = new ArrayList<String>(myResArrayList); 
like image 142
Valentin Rocher Avatar answered Oct 07 '22 19:10

Valentin Rocher