开发者

Array defining in Android Application

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

So could anyb开发者_StackOverflow中文版ody please help me how to do that on demand.


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);


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/


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...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜