title: Can I programmatically take a xml layout and reuse it?
body: <p>I have the following button</p>
  
  <pre><code>&lt;Button
  android:id="@+id/button1"
  style="?android:attr/buttonStyleSmall"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:minHeight="5dp"
  android:textSize="10sp"
  android:text="Button" /&gt;
  </code></pre>
  
  <p>Now in my code I want to programmatically make a dynamic amount of these buttons depending on certain factors.</p>
  
  <p>Now i have spent a fair amount of time trying to get the following code to work:</p>
  
  <pre><code> Button txtName = new Button(getActivity(), null, android.R.attr.buttonStyleSmall);
      txtName.setClickable(false);
      txtName.setTextSize(5);
      txtName.setMaxLines(1);
      txtName.setMaxHeight(40);
      txtName.setMinHeight(0);
      txtName.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
      txtName.setText(tagsList.get(i));
  </code></pre>
  
  <p>For some reason that code does not do what I want it to do. Please see my other question about that: <a href="https://stackoverflow.com/questions/18775470/how-to-programmatically-make-a-small-button-wrap-small-text">Other question</a></p>
  
  <p>However my question now is, can I take that layout code from the button above and then use it to make duplicate buttons like you would do with a list adapter?</p>
  
  <p>in other words I want one xml describing my buttons layout and I want it to be used for many buttons on the same page?</p>