Monday, March 15, 2010

[Java] Static Array Help in Eclipse/Android

 

I am just starting to work on building Android apps. I have some basic
knowledge of programming, but have never done any Java based stuff. I
apologize in advance for my questions being remedial. Most of what I do is
web based using ASP (vbscript) or PHP, plus I do some VBA.

I am just trying to figure out how to display a static array.

I have an arrays.xml file:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="history">
<item>Some text<item>
<item>more text<item>
<item>even more text<item>
</string-array>
</resources>

In my main.xml file I have:
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:text="@+id/history" android:layout_height="wrap_content"
android:layout_width="fill_parent"/>

I know that I need to decare my array. The code that I found to do this
is:
String[] history = getResources().getStringArray(R.array.history);

What I dont know is where in my main java file I put it. Currently my main
java file (TriumphHistory.java) looks like this:
package com.TriumphHistory.Soren;

import android.app.Activity;
import android.os.Bundle;

public class TriumphHistory extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}

Thanks for your help,
Soren

[Non-text portions of this message have been removed]

__._,_.___
Recent Activity:
Visit http://aiaiai.com or http://jgame.org for more groups to join.
Java Official Group is created for the following topics: Java 2 Enterprise Edition - J2EE, Java 2 Standard Edition - J2SE, Java 2 Micro Edition - J2ME, XML, XSL, XSD, XPATH, Web Services, Jini, JXTA for all type of Java Geeks.
Whoever posts spam / ads / job related message will be BANNED IMMEDIATELY
.

__,_._,___

No comments:

Post a Comment