Get & set text on view

To get a string/value:

EditText e1 = (EditText)findViewById(R.id.count2a);
	int i = Integer.parseInt(e1.getText().toString());

To set from an activity:

((TextView)findViewById(R.id.score)).setText(Integer.toString(score));

To set from a fragment:

((TextView)view.findViewById(R.id.textView1)).setText(myCurrency1);

To use a string from strings.xml:

((Button)findViewById(R.id.button2)).setText(R.string.sched_stop);

 

This entry was posted in Android. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *