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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:16:42+00:00 2026-06-01T16:16:42+00:00

I am creating a common place/class for all the action that can happen when

  • 0

I am creating a common place/class for all the action that can happen when a user clicks on AlertDialog option. I found this link but its not really helping me understand the concept. This is what I am looking to do.

  1. I have a class (ClassA) which extends from Activity and another class(ClassB) which extends from ListActivity.
  2. I have the alert dialog popping up regardless from where it is called.
  3. I have created a BaseRootActivity class which is extended in ClassA. Since ClassB extends from RootListActivity class, I am not able to invoke methods sitting inside the BaseRootActivity especially the ones which uses the context methods.

I can , based on the link, create two separate generic list Activities but the code would get duplicated in both the classes. I would like to avoid that. Is there a way I could do that, I understand the answer might be in the link given however, I am not really able to comprehend the underlying logic the user is stating. I would appreciate any help on this.

  • 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-01T16:16:43+00:00Added an answer on June 1, 2026 at 4:16 pm

    You should always prefer composition over inheritance. So, you have two good choices:

    • Just put the dialog logic in a third class that you will use from your ClassA and ClassB (not extending it, just using it).
    • Use the Fragments API (you can use the compatibility library to make it available on older versions of Android); there you can find a class called DialogFragment that basically forces you to create dialogs on separated classes (which is a great idea, by the way), and that will help you handle the problems you could face if you choose to follow the first choice.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm thinking about creating a mixin form class so that I can add a
I think the common idiom for creating instances of java.util.logging.Logger is this: public class
I have the presumably common problem of having elements that I wish to place
Creating a Drawable that is completely empty seems like a common need, as a
I'm looking into creating a library for myself that handles common internet-related functions. So
I'm creating a vsprops file to contain include and lib paths that are common
I'm creating a project to house an iPhone library for common code for the
Creating Traversals for Binary Search Tree with Recursion. void inOrder(void (*inOrderPtr)(T&)) { if(this->left !=
Creating liquid layouts is an immense pain. Now, I totally understand that tables should
Creating a google map with store locations within 50 miles of user entered address.

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.