Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the text inside a button

Tags:

android

<Button android:id="@+id/button1" android:text="blah blah">

How do I get the text inside android:text?

like image 583
drdrdr Avatar asked Sep 16 '11 09:09

drdrdr


2 Answers

Button btn = (Button)findViewById(R.id.button1);
String buttontext = btn.getText().toString();

Hope this will help you.

like image 175
Pattabi Raman Avatar answered Oct 01 '22 11:10

Pattabi Raman


you get text by.

Button button = (Button) findViewById(R.id.button1);
String yourText = (String)button.getText();
like image 28
Yashwanth Kumar Avatar answered Oct 01 '22 10:10

Yashwanth Kumar