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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:18:37+00:00 2026-06-03T17:18:37+00:00

When my alert pops up I want it to dismiss when it is touched

  • 0

When my alert pops up I want it to dismiss when it is touched again with out adding any buttons to it.

so on a map pin touch

@Override
    protected boolean onTap(int i) {
        OverlayItem item = items.get(i);    
        dialog.setTitle(item.getSnippet());
        dialog.setMessage(item.getTitle());
        dialog.show();
        return (true);
    }

So how do I make it go away by touching any where in the alert or the background.

EDIT:ADDED CODE

 private class SitesOverlay extends ItemizedOverlay<CustomItem> {
private Drawable heart=null;
private List<CustomItem> items=new ArrayList<CustomItem>();
private PopupPanel panel=new PopupPanel(R.layout.popup);

public SitesOverlay() {
  super(null);

  heart=getMarker(R.drawable.heart_full);

  JSONObject json;
  JSONObject json2;
  String resultURL = queryRESTurl("http://www.kickintheapp.com/api/maps393/json.json");
  try {
      json = new JSONObject(resultURL);

  JSONArray nameArray = json.names();

  JSONArray valArray;

      valArray = json.toJSONArray(nameArray);


  for (int i = 0; i < valArray.length(); i++) 
  {

      Log.e(nameArray.getString(i), valArray.getString(i));
      json2 = new JSONObject(valArray.getString(i));
      JSONArray nameArray2 = json2.names();

      JSONArray valArray2 = json2.toJSONArray(nameArray2);
      for (int a = 0; a < valArray2.length(); a++) 
      {

          // add to maps here
          items.add(new CustomItem(getPoint(valArray2.getDouble(3),valArray2.getDouble(2)), valArray2.getString(1), valArray2.getString(0),getMarker(R.drawable.pin_yellow), heart));
          Log.e(nameArray2.getString(a), valArray2.getString(a));
      }
   }
  } catch (JSONException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
  }

  populate();
}

@Override
protected CustomItem createItem(int i) {
  return(items.get(i));
}

@Override
public void draw(Canvas canvas, MapView mapView,
                  boolean shadow) {
  super.draw(canvas, mapView, shadow);

}

@Override
protected boolean onTap(int i) {
    OverlayItem item=getItem(i);
    GeoPoint geo=item.getPoint();
    Point pt=map.getProjection().toPixels(geo, null);

    View view=panel.getView();

    ((TextView)view.findViewById(R.id.latitude))
      .setText(item.getSnippet());
    ((TextView)view.findViewById(R.id.longitude))
      .setText(item.getTitle());

    panel.show(pt.y*2>map.getHeight());

    return(true);
}

class PopupPanel {
   View popup;
   boolean isVisible=false;

 PopupPanel(int layout) {
   ViewGroup parent=(ViewGroup)map.getParent();

   popup=getLayoutInflater().inflate(layout, parent, false);

   popup.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
      hide();
    }
  });
}

View getView() {
  return(popup);
}

void show(boolean alignTop) {
  RelativeLayout.LayoutParams lp=new RelativeLayout.LayoutParams(
        RelativeLayout.LayoutParams.WRAP_CONTENT,
        RelativeLayout.LayoutParams.WRAP_CONTENT
  );

  if (alignTop) {
    lp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    lp.setMargins(0, 20, 0, 0);
  }
  else {
    lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    lp.setMargins(0, 0, 0, 60);
  }

  hide();

  ((ViewGroup)map.getParent()).addView(popup, lp);
  isVisible=true;
}

void hide() {
  if (isVisible) {
    isVisible=false;
    ((ViewGroup)popup.getParent()).removeView(popup);
  }
 }
}
  • 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-03T17:18:40+00:00Added an answer on June 3, 2026 at 5:18 pm

    Any particular reason not to use PopupWindow? It allows you being notified for “inside” and “outside” touch events very easily.

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

Sidebar

Related Questions

Let's say I want that every time the user click any link an alert
I want to create a SQL Server database in App_Data folder, but alert pops
What I want to happen, in order: Alert box pops up saying processing (no
I want a web page that pops up a JavaScript alert when a bar
I'm trying to get it so that the alert message pops up if the
We alert user using this javascript, now i want to add this functionality to
i have an alert box which i want to show some icelandic text but
I have an SQL query with a question(alert like) that pops up every time
I want to alert the user that the session timeout is about to expire.
I have an alert that pops up when a user clicks on a delete

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.