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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:19:18+00:00 2026-05-23T03:19:18+00:00

I want to extend the functionality of the ImageButton class, in a new class

  • 0

I want to extend the functionality of the ImageButton class, in a new class I choose to call “DialButton”. To start off, I simpy extend ImageButton, and added nothing new. In my mind, this should be identical to the normal ImageButton class.

package com.com.com;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ImageButton;

public class DialButton extends ImageButton{

    public DialButton(Context context) {
        super(context);
        // TODO Auto-generated constructor stub
    }

    public DialButton(Context context, AttributeSet attrs) {
        super(context, attrs);
        // TODO Auto-generated constructor stub
    }

    public DialButton(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        // TODO Auto-generated constructor stub
    }

}

I insert a DialButton in XML (dont worry about the rest of the file, its irrelevant)

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:stretchColumns="1">
    <TableRow
    android:layout_weight="1">
        <DialButton
            android:id="@+id/button1"
            android:background="@drawable/dialpad"
            android:layout_weight="1"/>

And use the XML in my activity:

package com.com.com;

import android.app.Activity;
import android.os.Bundle;

public class Android3 extends Activity {

    DialButton button1;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.maintable);   
    }
}

Everything compiles and installs in the emulator but when the app starts it force closes on me. If I change the XML component from a DialButton to an ImageButton, everything works fine. Why is this? What is the difference between the ImageButton class and my DialButton class that causes the DialButton component to crash the app?

  • 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-23T03:19:19+00:00Added an answer on May 23, 2026 at 3:19 am

    In your layout file, you have to provide a ‘fully-qualified’ name for your custom widgets as follows…

    <com.mycompany.myapp.DialButton
        android:id="@+id/button1"
        android:background="@drawable/dialpad"
        android:layout_weight="1"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to extend a WPF application with database functionality. Which database engine would
In following code, I want to extend the behaviour of a class by deriving/subclassing
I currently have a codebase of delphi (win32) code. I want to extend new
I want to extend a base class in apache commons email, the base class
I want to extend the basic ControlCollection in VB.NET so I can just add
I want to extend an existing application I made to make it set mixer
I need some advice. I have a web page and want to extend it's
Basically, I want the C# compiler functionality of its override keyword in my C++
I want to provide common functionality between different activity types such as opening and
I want to achieve Virtual Space functionality, similar to one in Visual Studio, in

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.