this is my first time making a question here i hope i'm doing it right, my question is if there's a way to pass a text to a XML element in android without having to do it through the setContentView() so i can pass the text to a specific element and not have it as the whole content in the activity. thanks in advance.
Asked
Active
Viewed 60 times
-1
-
does http://stackoverflow.com/questions/2300169/how-to-change-text-in-android-textview help? – dsrees Feb 17 '14 at 01:36
2 Answers
0
You can have the TextView be a part of the layout, and then use findViewById() to obtain a pointer to the TextView (without having the TextView take up the entire content of the layout).

Michael Aaron Safyan
- 93,612
- 16
- 138
- 200
-
this is the code i have but it crash every time i press the button that take me to the activity with this code. Intent intent = getIntent(); String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE); TextView textview = (TextView) findViewById(R.id.textview1); textview.setTextSize(40); textview.setText(message); – user3317343 Feb 17 '14 at 02:43
0
TextView tv = (TextView) findViewById(R.id.sometextview);
tv.setText("whatever you want");

WIllJBD
- 6,144
- 3
- 34
- 44