tags:

views:

45

answers:

3

I want to use the concept of array in my Android Application, I don't know how to do that actually.

So could anybody please help me how to do that on demand.

A: 

This defines an array of 5 strings:

String[] stringArray = new String[5];

However, I can not imagine that this is really what you're talking about...

CLARIFICATION
If you actually don't know what an array is, then my reply will give you a hint. In case you're talking about something else, this reply should indicate that you're not giving enough detail. You might as well be talking about this...

Thorsten Dittmar
+1  A: 

There are alot of different "array" types in java... there are actual arrays like Thorsten showed you and then there are lists, collections and hashes. Take you pick. :) A great place to start learning more about Java is the docs.

http://download.oracle.com/docs/cd/E17409_01/javase/6/docs/

http://download.oracle.com/docs/cd/E17409_01/javase/tutorial/

androidworkz
+1  A: 

I guess you are talking about arrays in Android through the res folder.

Create an array.xml inside the /res/values folder with something like this:

<?xml version="1.0" encoding="utf-8"?>
 <resources>
  <string-array name="names_list">
   <item>John</item>
   <item>Peter</item>
   <item>Charles</item>
  </string-array>
 </resources>

You can get that array on your Activity by doing:

getResources().getStringArray(R.array.names_list);
Macarse