Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7775373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:36:52+00:00 2026-06-01T17:36:52+00:00

I have several buttons in my current app. They are all identical except for

  • 0

I have several buttons in my current app. They are all identical except for their text and a tag. The main.xml would be a lot nicer if I didn’t have to repeat all the button config information for each button.

Is there a way to define a button as template, and then make more using it as a template?

In this example, I have about 10 of the following:

 <Button
            android:id="@+id/button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="10dp"
            android:text="Y"
            android:typeface="monospace"
            android:textSize="12pt"
            android:tag="Y"
            android:textColor="@color/button_text"
            android:background="@drawable/grey_blank_48x48"
            android:onClick="onButtonClicked"/>

It would be nice if I had one, and then 9 of these:

 <Button2
            android:text="N"
            android:tag="N"/>

Resolution

It was pretty much as @Luksprog said:

<style name="ASR33_button" >
    <item name="android:id">@+id/button</item>
    <item name="android:layout_width">wrap_content</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:padding">10dp</item>
    <item name="android:textColor">@color/button_text</item>
    <item name="android:background">@drawable/grey_blank_48x48</item>
    <item name="android:onClick">onButtonClicked</item>
    <item name="android:typeface">monospace</item>
    <item name="android:textSize">12pt</item>
</style>

with the main.xml having things like this:

   <Button
            style="@style/ASR33_button"
            android:tag="Y"
            android:text="Y"
            />

   <Button
            style="@style/ASR33_button"
            android:tag="N"
            android:text="N"
            />

This carries the day.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T17:36:53+00:00Added an answer on June 1, 2026 at 5:36 pm

    Us a style:

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <style name="btnlook" >
            <item name="android:id">@+id/button</item>
            <item name="android:layout_width">wrap_content</item>
            <item name="android:layout_height">wrap_content</item>
            <item name="android:padding">10dp</item>
            <item name="android:textColor">@color/button_text</item>
            <item name="android:background">@drawable/grey_blank_48x48</item>
            <item name="android:onClick">onButtonClicked</item>
            <item name="android:typeface">monospace</item>
            <item name="android:textSize">12pt</item>
        </style>
    </resources>
    

    and then in your xml layout:

    <Button
                style="@style/btnlook"
                android:text="N"
                android:tag="N"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several buttons on my app that are being created dynamically. They are
I have a winforms app and the main (and only) form has several buttons.
What I want to do is have several radio buttons all on a different
I have several buttons in various sizers and they expand in the way that
In my layout xml file I have several buttons like this which share the
I have several forms on one page, they're all the same, but have different
I have several radio buttons that are dynamically populated on a form and I
I have put several buttons and panels in my update panel. I also have
I've some CSS problem in Firefox 3. I have several image buttons on my
I have several wpf pages with update/delete/add buttons. I want to display to the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.