Question: I want to programatically add buttons in android, the xml file for the button would be

```
<Button
android:textStyle="bold"
android:background="@drawable/blue"
android:textColor="@drawable/blue_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/funny_excuses"
android:id="@+id/funny"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:textSize="25sp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />

```

What is the best way to do it?
I will only change the text for each new button..
And maybe I will have another button type, like with other background and textcolor..

Answer: 
Also its possible to create this Button xml and inflate layout recource from code:
button.xml:

```
<Button
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:textStyle="bold"
 android:background="@drawable/blue"
 android:textColor="@drawable/blue_text"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="@string/funny_excuses"
 android:id="@+id/funny"
 android:paddingBottom="10dp"
 android:paddingTop="10dp"
 android:paddingLeft="6dp"
 android:paddingRight="6dp"
 android:textSize="25sp"
 android:layout_alignParentTop="true"
 android:layout_centerHorizontal="true" />

```

code:

```
    Button button = (Button) getLayoutInflater().inflate(R.layout.button, null);
    button.setText("Hello world");
    RelativeLayout ll = (RelativeLayout) findViewById(R.id.ll); //layout to add
    ll.addView(button);

```
ok do one thing.only you want to change the button text.so, programmatically for button object keep setText() and setBackground()...