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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:07:10+00:00 2026-05-29T08:07:10+00:00

ive been trying to pop up a custom dialog box when tapping on a

  • 0

ive been trying to pop up a custom dialog box when tapping on a marker of the google map. I use this code to override onTap() method of itemizedOverlay calss.

protected boolean onTap(int index) {
            AlertDialog.Builder builder;
            AlertDialog alertDialog;

            Context mContext = getApplicationContext();
            LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE);
            View layout = inflater.inflate(R.layout.custom_dialog,
                                           (ViewGroup) findViewById(R.id.layout_root));

            TextView textName = (TextView) layout.findViewById(R.id.text);
            textName.setText("Here is the Name");

            ImageView image = (ImageView) layout.findViewById(R.id.image);
            image.setImageResource(R.drawable.ic_launcher);


            builder = new AlertDialog.Builder(mContext);
            builder.setView(layout);

            alertDialog = builder.create();
            alertDialog.show();

            return super.onTap(index);
        }

Here is the custom dialog layout xml.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/layout_root"
          android:orientation="horizontal"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:padding="10dp"
          >
<ImageView android:id="@+id/image"
           android:layout_width="wrap_content"
           android:layout_height="fill_parent"
           android:layout_marginRight="10dp"
           />
<TextView android:id="@+id/text"
          android:layout_width="wrap_content"
          android:layout_height="fill_parent"
          android:textColor="#FFF"
          />

But i get this exception when tapping on a marker

02-07 16:46:51.768: E/AndroidRuntime(315): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application

this is the exact example given on http://developer.android.com/guide/topics/ui/dialogs.html

any help please…

Thanks.

  • 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-29T08:07:12+00:00Added an answer on May 29, 2026 at 8:07 am

    Use classname.this instead of getApplicationContext
    if its a simple mapactivity

    if its in tab then use getParent()

    because badtokenexception occur when its not take right class reference.

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

Sidebar

Related Questions

Ive been trying to figure this one out for a while. I need to
Ive been trying to get the parent of this WebBrowser control. Somehow i can't
Ive been trying to acheive the same, this is exactly what i want :-
I've been exploring the use of custom functions for event handlers. In this stripped
Ive been trying to debug this for hours but I was unable to get
Ive been trying to display formatted content blocks from a xml file with no
Ive been playing around with delegates trying to learn and I ran into one
i am trying to create a fade effect with the following...ive been told im
Ive been tryin to solve this for a long time and now know why
I've been trying to use SQLite with the PDO wrapper in PHP with mixed

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.