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 8417235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:59:03+00:00 2026-06-10T01:59:03+00:00

So here’s my problem: I’ve created a custom component which extends the Button This

  • 0

So here’s my problem: I’ve created a custom component which extends the Button This button has one attribute called testAttr.

<declare-styleable name="TestButton" parent="@android:style/Widget.Button">
    <attr name="testAttr" format="reference|color"/>
</declare-styleable>

I want to create a default style for this component so i added this:

<declare-styleable name="TestTheme">
    <attr name="testStyle" format="reference"/>
</declare-styleable>

<style name="Theme.AppTheme" parent="@android:style/Theme" >
    <item name="testStyle">@style/test</item>
</style>

The problem is that i want to use both android attributes and my own like this, which isn’t working:

<style name="test" parent="@android:style/Widget.Button">
    <item name="android:background">#FF0000</item>
    <item name="testAttr">testText</item>
</style>

I set the default styles in my custom component as follows:

public myButton(final Context context) {
    this(context, null);
}

public myButton(final Context context, final AttributeSet attrs) {
    this(context, attrs, R.styleable.TestTheme_testStyle);
}

public myButton(final Context context, final AttributeSet attrs, final int defStyle) {
    super(context, attrs, defStyle);

    final TypedArray array = context.obtainStyledAttributes(
            attrs,
            R.styleable.TestButton,
            defStyle,
            R.style.testDefault);
        final String s = array.getString(R.styleable.TestButton_testAttr);
        setText(s);
        array.recycle();
}

And of course i set the Theme in the manifest:

<uses-sdk
    android:minSdkVersion="7"
    android:targetSdkVersion="15" />

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/Theme.AppTheme" >

    <activity
        android:name=".TestActivity"
        android:label="@string/title_activity_main" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>


</application>

It always falls back to the default style for some reason and never sets the android attributes. So am i missing something here?

  • 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-10T01:59:04+00:00Added an answer on June 10, 2026 at 1:59 am

    Well, I should’ve looked better before asking questions…

    found the solution:

    replaced this:

    public myButton(final Context context, final AttributeSet attrs) {
        this(context, attrs, R.styleable.TestTheme_testStyle);
    }
    

    with this:

    public myButton(final Context context, final AttributeSet attrs) {
        this(context, attrs, R.attr.testStyle);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's the problem, I want to change play button to pause button when the
Here's a coding problem for those that like this kind of thing. Let's see
Here is the code in a function I'm trying to revise. This example works
Here is my problem : I have a post controller with the action create.
Here is an example. foreach (var doc in documents) { var processor = this.factory.Create();
Here's what I'm trying to accomplish with this program: a recursive method that checks
Here is the css: #content ul { font-size: 12px; } I am trying this:
Here my problem: @Assert\Regex( * pattern=/^[A-Za-z0-9][A-Za-z0-9\]*$/, * groups={creation, creation_logged} * ) I'm using the
Here is an example: I have the generic type called Account. I wish to
Here is the problem that I am trying to solve. I have two folders

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.