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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:23:00+00:00 2026-05-23T05:23:00+00:00

I have created a custom RadioButton for my Android app which just replaces the

  • 0

I have created a custom RadioButton for my Android app which just replaces the standard radio button with custom images. Now I want to have the text label that would usually appear to the right of the standard button appear overlapping the custom button in it’s center.

Is there a way to do this?

UPDATE: Here is my attempt at create a custom component to do this:

public class RadioButtonText extends RadioButton {
    Paint myPaint = new Paint();

    public RadioButtonText(Context context) {
        super(context);
    }

    public RadioButtonText(Context context, AttributeSet attrbs) {
        super(context, attrbs);
    }

    @Override
    protected void onDraw (Canvas canvas) {
        super.onDraw(canvas);
        String myText = (String) getText();
        canvas.drawText(myText, 10, 10, myPaint);
    }       
}

And here is my using it in my layout.xml:

<view
    class="com.stickfigs.blockball.BlockBallLevelSelect$RadioButtonText"
    android:button="@drawable/bb_button"
    android:id="@+id/levelButton0"
    android:layout_height="96px"
    android:layout_width="96px"
    android:textColor="#fff"
    android:text="1">
</view>

But when I try to run the app I get this error:

06-11 22:16:32.642: ERROR/AndroidRuntime(323): Caused by: android.view.InflateException: Binary XML file line #16: Error inflating class com.stickfigs.blockball.BlockBallLevelSelect$RadioButtonText
06-11 22:16:32.642: ERROR/AndroidRuntime(323):     at android.view.LayoutInflater.createView(LayoutInflater.java:503)
06-11 22:16:32.642: ERROR/AndroidRuntime(323):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
06-11 22:16:32.642: ERROR/AndroidRuntime(323):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
06-11 22:16:32.642: ERROR/AndroidRuntime(323):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
06-11 22:16:32.642: ERROR/AndroidRuntime(323):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
06-11 22:16:32.642: ERROR/AndroidRuntime(323):     at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
06-11 22:16:32.642: ERROR/AndroidRuntime(323):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
06-11 22:16:32.642: ERROR/AndroidRuntime(323):     at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
06-11 22:16:32.642: ERROR/AndroidRuntime(323):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
06-11 22:16:32.642: ERROR/AndroidRuntime(323):     at android.app.Activity.setContentView(Activity.java:1647)
06-11 22:16:32.642: ERROR/AndroidRuntime(323):     at com.stickfigs.blockball.BlockBallLevelSelect.onCreate(BlockBallLevelSelect.java:30)
06-11 22:16:32.642: ERROR/AndroidRuntime(323):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-11 22:16:32.642: ERROR/AndroidRuntime(323):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
06-11 22:16:32.642: ERROR/AndroidRuntime(323):     ... 11 more
06-11 22:16:32.642: ERROR/AndroidRuntime(323): Caused by: java.lang.NoSuchMethodException: RadioButtonText(Context,AttributeSet)
06-11 22:16:32.642: ERROR/AndroidRuntime(323):     at java.lang.Class.getMatchingConstructor(Class.java:660)
06-11 22:16:32.642: ERROR/AndroidRuntime(323):     at java.lang.Class.getConstructor(Class.java:477)
06-11 22:16:32.642: ERROR/AndroidRuntime(323):     at android.view.LayoutInflater.createView(LayoutInflater.java:475)
06-11 22:16:32.642: ERROR/AndroidRuntime(323):     ... 23 more
06-11 22:16:32.662: WARN/ActivityManager(42):   Force finishing activity com.stickfigs.blockball/.BlockBallLevelSelect
06-11 22:16:33.198: WARN/ActivityManager(42): Activity pause timeout for HistoryRecord{43edc648 com.stickfigs.blockball/.BlockBallLevelSelect}

What am I doing wrong?

  • 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-05-23T05:23:01+00:00Added an answer on May 23, 2026 at 5:23 am

    RadioButtonText is an inner class of BlockBallLevelSelect. you cannot instantiate an instance of it without an existing outer class object. As such, you will need to mark RadioButtonText as static to reference the type in XML.

    As a side note, since it will be static it no longer makes a lot of sense to leave it as an inner class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a custom drawable for RadioButton's button drawable. I have created
i have created custom components in flex where i have used a button,i want
In my app i have created custom cell with 2labels and one check button.when
I have UITableView.In that i have created custom cell with accessory button.Now by clicking
I have created custom posts and I want one page in my site to
I have created custom cell in which there are n number of image views.
If have created a custom role within SqlServer which I added to the db__denydatareader
I have created custom workflow and successfully deployed it on Alfresco. I just copied
I have created custom result class to serialize json data to xml. I want
I have created Custom User Control which contain TextBox and PasswordBox. it is binding

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.