Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I reuse this Android button?

I have a Button that I am using 13 times in my Android application's main.xml file. I would like to have the XML for it defined once, so that I can make changes in one place instead of 13. Each of the 13 instances needs to have its own ID, though. What should I do to simplify my XML? I've tried using <include> but it hasn't worked for me. I must have been doing something wrong. I'd appreciate it if anyone could show me how to do it correctly. Thanks.

Here's the XML for the button that I'd like to reuse:

<Button
  android:width="70dp" 
  android:layout_marginLeft="10dp"
  android:layout_marginRight="10dp" />
like image 844
A.J. Avatar asked Jul 27 '10 05:07

A.J.


1 Answers

You should use Styles and Themes for that sort of things.

like image 136
Macarse Avatar answered Oct 20 '22 23:10

Macarse