I have multiple different categories and in each category I use one string resource to populate a ListView like so:
<string-array name="list">
<item>item1</item>
<item>item2</item>
<item>item3</item>
</string-array>
I call them like so:
String[] list = getResources().getStringArray(R.array.list);
How can I combine these into one String[] to use as an "All" list.
asked Jun 5, 2012 at 2:37
1 Answer 1
you can combine two Array List into a single one Like this:
ArrayList<String> first;
ArrayList<String> second;
second.addAll(first);
Since you use Simple Array there a multiple way to change arrays to arrayList, you can fetch for it on the net. But why you are not storing them on a single array in xml file that you call it global_content for exemple. You are waisting time and memory for this!!
answered Jun 5, 2012 at 2:53
3 Comments
GreekOphion
How do I do that if I had like 10 of them?
GreekOphion
And also, I am using arrays, Not arrayLists
K_Anas
there a multiple way to change array to arrayList you can find it on the net. but why you are not storing them on a single array in xml file. for the approach i give it to you: you can use: array10.addAll(array9.addAll(array8)) but i advice you to store them on a single array that you will call it global_content or something like that
default