tags:

views:

24

answers:

2

The text on my buttons are set in resource files. E.g.

            <Button android:id="@+id/up_button" android:layout_width="fill_parent"
                android:layout_height="wrap_content" android:text="@string/up_label" />

The above code defines a button with text @string/up_label. How can I change this text in my program during the application is running.

Thanks.

+3  A: 
Button myButton = (Button) findViewById(R.id.up_button);
myButton.setText("my dirty text")`

maybe this will help.

Marco Schmid
+1  A: 

Or, if you have the new text in resources (which I think you do), you do

Button myButton = (Button) findViewById(R.id.up_button);
myButton.setText(R.string.down_label);

where down_label is the id of your string.

neutrino