0

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

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

How do I do that if I had like 10 of them?
And also, I am using arrays, Not arrayLists
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

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.