I have an onTouch method that creates a new GeoPoint where the user
touches the screen. It then opens a dialog box and asks them for a
name for this GeoPoint. This method is shown below:

        @Override
        public boolean onTouchEvent(MotionEvent event, MapView mapView) {
                if(event.getAction() == MotionEvent.ACTION_DOWN) {
                        if (add == true) {
                                this.add = false;
                                this.p = proj.fromPixels((int)event.getX(), 
(int)event.getY());
                            LayoutInflater li = LayoutInflater.from(mContext);
                        View view = li.inflate(R.layout.adddialog, null);
                        winAlert = new AlertDialog.Builder(mContext)
                                .setIcon(R.drawable.marker)
                                .setTitle("Add a new POI")
                                .setPositiveButton("Save", mOnClickListener)
                                .setNegativeButton("Cancel", mOnClickListener)
                                .setView(view);
                        winDialog = winAlert.create();
                        winDialog.show();
                        }
                }
                return false;
        }

Now when the Save button is clicked, this method is called to add the
point:

        OnClickListener mOnClickListener = new OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                        // TODO Auto-generated method stub
                        switch(which) {
                        case -1:
                                add_dialog_editText = (EditText) 
winDialog.findViewById
(R.id.add_dialog_editText);
                                addLocation(p, "Test", 
add_dialog_editText.getText().toString());
                                break;
                        case -2:
                                dialog.cancel();
                                return;
                        }
                }
        };

My add location method looks like this:

        public void addLocation(GeoPoint p, String title, String desc) {
                OverlayItem overlayItem = new OverlayItem(p, title, desc);
                this.addOverlay(overlayItem);
                mapOverlays.add(this);
        }

Now my issue is that my points will not display on the map unless

1) I add an initial point in the constructor of this class
2) Even after I add an initial point in the constructor, the points
don't show up until I touch the screen once more (anywhere).

I find if I comment out the dialog and put a static description the
points show up immediately so there must be something in the Dialog
that doesn't update until the user clicks the screen after the dialog
has been closed? I really don't understand why this is behaving like
this, can someone give me some help?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to