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

  • Home
  • SEARCH
  • 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 6710269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:00:08+00:00 2026-05-26T08:00:08+00:00

I am creating one parent Activity(Class) and then want to extends this class to

  • 0

I am creating one parent Activity(Class) and then want to extends this class to another Activity(Class). I have some controls in all the Activities(Classes) so I decide to use Abstract class so that I need not write some common code in all the classes.I created below classes and one of it is abstract class.When I am calling my Welcomepage Activity this will display me a screen with all common controls(Radio buttons in my case).In Abstract class I had set checkedChangedListener listener and in onCheckedChanged() method I am creating a toast but It is not displaying.I am confused in this case.What is the reason to not displaying a toast?.

My Activity(Class) Welcomepage_pillReminder which extends CustomTabsActivity

public class Welcomepage_pillReminder extends CustomTabsActivity

    @Override
    public void mappingWidgets() {
        super.mappingWidgets();

    }

@Override
    public void addCheckChangedListner() {
        super.addCheckChangedListner();
    }

CustomActivity

public abstract class CustomTabsActivity extends Activity {
    protected RadioButton radHome;

    public void mappingWidgets(){
        radHome = (RadioButton)findViewById(R.id.radHome);
    }
    public void addCheckChangedListner() {
        radHome.setOnCheckedChangeListener(onCheckedChangeListener);
    }


    OnCheckedChangeListener onCheckedChangeListener = new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if(isChecked) {
                if(buttonView.getText().equals("Home")) {
                    Toast.makeText(getApplicationContext(), "Home", 2000).show();
                }   
            }
        }
    };
}
  • 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-26T08:00:08+00:00Added an answer on May 26, 2026 at 8:00 am

    You can do it like this,

    Your CustomActivity.java

    public class CustomActivity extends Activity implements OnClickListener{
    
        public void initLayout(Button button){
            button.setOnClickListener(this);
        }
         public void simple_method(){
                System.out.println("test in CustomActivity");
            }
    
        @Override
        public void onClick(View v) {
            Toast.makeText(getApplicationContext(), "Button Clicked in Custom Activity", Toast.LENGTH_LONG).show();
        }
    }
    

    Activity that extends CustomActivity
    CustomClassDemoActivity.java

      public class CustomClassDemoActivity extends CustomActivity{
        Button button;
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            button = (Button) findViewById(R.id.myTextView);
            button.setText("This is a Custom Activity Example");
            super.initLayout(button);
            simple_method();
        }
    
        public void simple_method(){
            super.simple_method();
            System.out.println("test in mainClass");
        }
        @Override
        public void onClick(View v) {
            super.onClick(v);
            Toast.makeText(getApplicationContext(), "Button Clicked in Main Activity", Toast.LENGTH_LONG).show();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a one-to-many relationship. so, i have a parent and a child.
I want to display 3 different websites one after another by creating their respective
I have two app domains, one parent creating the child domain. In the child
I am creating one GUI in swing Java. I have to use one button
I'm looking for some pros and cons of creating one operation per wdsl against
When creating a subscription on reporting services 2008 one is unable to select all
I'm creating a generic class and in one of the methods I need to
Have a tough one here! I'm creating a blogger template, and the client wants
I've ran into one small problem. I am dynamically generating some controls and place
Often I'm creating reports in Visual Studio's Crystal Reports and want to have a

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.