I'm having a problem with setting text to a TextView:
TextView android:editable = "true".
In my .java it seems like that this should work:
text = (EditText) findViewById(R.id.this_is_the_id_of_textview);
text.setText("TEST");
But it doesn't. Can anyone tell me what's wrong here?
Set The Text of The TextView You can set the text to be displayed in the TextView either when declaring it in your layout file, or by using its setText() method.
TextView tv1 = (TextView)findViewById(R. id. textView1); tv1. setText("Hello"); setContentView(tv1);
String a = tv. getText(). toString(); int A = Integer. parseInt(a);
SetText(String, TextView+BufferType)Sets the text to be displayed using a string resource identifier.
The code should instead be something like this:
TextView text = (TextView) findViewById(R.id.this_is_the_id_of_textview);
text.setText("test");
In your java class, set the "EditText
" Type to "TextView
". Because you have declared a TextView
in the layout.xml
file
To settext in any of in activity than use this below code... Follow these step one by one:
1.Declare
private TextView event_post;
2.Bind this
event_post = (TextView) findViewById(R.id.text_post);
3.SetText in
event_post.setText(event_post_count);
Try Like this :
TextView text=(TextView)findViewById(R.id.textviewID);
text.setText("Text");
Instead of this:
text = (EditText) findViewById(R.id.this_is_the_id_of_textview);
text.setText("TEST");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With