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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:44:44+00:00 2026-05-31T16:44:44+00:00

Im asking to see if anyone could help me with my problem which is

  • 0

Im asking to see if anyone could help me with my problem which is that I have a custom dialog box in a java class. This custom dialog box has a button which when pressed will call a method from my activity class. When I run the code nothing happens, it seems that the method is never being called and also no errors are given, the reason that im trying it this way is because the java class is being used for overlayitems. Below is a snippit of the code that I have, cheers to anyone who has insight on the problem

Java Class for overlayitem

    public boolean onTap(int index) {
    OverlayItem item = mapOverlays.get(index);
    Dialog dialog = new Dialog(context);

    dialog.setContentView(R.layout.dialog);
    dialog.setTitle(item.getTitle());

    TextView text = (TextView) dialog.findViewById(R.id.text);
    text.setText(item.getSnippet());
    Button CallButton = (Button) dialog.findViewById(R.id.CallButton);
    CallButton.setOnClickListener(new View.OnClickListener()
    {
        public void onClick(View v) 
        {
            try {
                TheActivityClass.showMessage();
            } catch (Exception e) {
                // TODO Auto-generated catch block

            }
        }
    }
    );
    dialog.show();
    return true;

}

Activity Class

public void showMessage(){



        Context context = getApplicationContext();
        CharSequence text = "I have just been pressed";
        int duration = Toast.LENGTH_SHORT;

        Toast toast = Toast.makeText(context, text, duration);
        toast.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-31T16:44:46+00:00Added an answer on May 31, 2026 at 4:44 pm

    You have an encapsulation problem… The activity class is not on the top of the current stack and the showMessage() method is not static.

    You should be controlling the application logic from inside the Activity class not the Java overlay class (follow the MVVM logic ie MVC where the activity is your controller). The best option would be to encapsulate the dialog/overlay object in the Activity and set the logic within the Activity class (create appropriate methods in the overlay class to do this) or to just make your overlay and inner class of the Activity. This will allow you do to what you are trying to do.

    Hope that helps.

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

Sidebar

Related Questions

Humbly asking for help with (of course) IE. I have a div that is
I often see people asking XML/XSLT related questions here that root in the inability
Asking for your help on this Oracle query. It's giving me the error 2
There is one thing that bothers me, C++ function pointers. I'm asking this question
I'm not asking for anyone to do this homework for me, but I bring
I can see people asking all the time whether multiple inheritance should be included
I see questions every day asking how to parse or extract something from some
After asking this question I was advised not to check in binaries into subversion.
I am new to Python and this is my first time asking a stackOverflow
I am building a Facebook application which should not be viewable to anyone under

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.