i have two text views in my linear layout and dynamically text get displayed. Now how to convert that text view to a string in my application.
Asked
Active
Viewed 1.2k times
-1
-
You can use `TextView.getText().toString();` – Apoorv Dec 19 '13 at 08:10
-
you can get the string value like `textView.getText().toString()` – Raghunandan Dec 19 '13 at 08:10
-
possible duplicate of [Converting TextView to String (kind of) Android](http://stackoverflow.com/questions/3928864/converting-textview-to-string-kind-of-android) – Shayan Pourvatan Dec 19 '13 at 08:21
2 Answers
5
suppose your textview name is tv1 then try
String input = tv1.getText().toString();

Nambi
- 11,944
- 3
- 37
- 49
1
You cant change textview to string but you can get string from textview. This is for textview:
TextView textView;
textView = (TextView) findViewById(R.id.tv_1);
textView.setText("AFJHDFGKS");
then to get text as string:
String text = textView.getText().toString();

keshav
- 3,235
- 1
- 16
- 22