0

I have this code:

ArrayList<ArrayList<String>> row = new ArrayList<ArrayList<String>>();
ArrayList<String> column = new ArrayList<String>();

my problem is I can't add String to it. How can I add String from a TextView(in Android)?

1
  • 1
    do you want add string to column or row? Commented Sep 25, 2012 at 23:41

2 Answers 2

3

Assuming you have declared your TextView in xml (replace myTextView with your TextView's id):

TextView tv = (TextView) findViewById(R.id.myTextView);
int index = 0;//change to index in row that you want to modify
String text = tv.getText().toString();
ArrayList<String> col = row.get(index);
if (col == null) {
    col = new ArrayList<String>();
    col.add(text);
    row.add(col);
}
else {
    col.add(text);
}
Sign up to request clarification or add additional context in comments.

Comments

1
ArrayList<ArrayList<String>> row = new ArrayList<ArrayList<String>>();
ArrayList<String> column = new ArrayList<String>();
row.add(column);
column.add(myString);

String theString = row.get(0).get(0);

Comments

Your Answer

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.