-1

Was looking through the forums, but I couldn't find a precise answer. Hope someone can help me out. I'm fairly new at programming.

I have the following list of strings in a class. (in Schedule.java):

String[][] schedule = {
{"English", "Music", "Math", "French", "Physics", "Chemistry"},
{"Contemp.", "Math", "French", "Chemistry", "Phys Ed", "English"}
};

How would I be able to 'access' these strings from another class? (ActivityMain.java)

For example, in ActivityMain.java , I want to pull: schedule[0][1] which would be "Music" and then set that in a TextView in ActivityMain.java.

How would I be able to get the string "Music" from Schedule.java to MainActivity.java ?

Unheilig
  • 16,196
  • 193
  • 68
  • 98

2 Answers2

0

You can use public method putStringArraylistExtra of Intent. Please refer developer android site.

Debashis
  • 898
  • 8
  • 9
0

From the information given - assuming "Schedule.java" is just a POJO and not an activity - one way is to create a "Schedule" object in your ActivityMain class, so you can pull "Music" from the schedule array and update your text view. Make sure the schedule array has more private accessibility, or you can write getters in Schedule.java to return the relevant strings.

henrykodev
  • 2,964
  • 3
  • 27
  • 39