Application Dialog Issues

Put your problem here if it does not fit any of the other categories.

Application Dialog Issues

Postby aspekt9 » Sun Jul 05, 2009 1:12 am

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:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         @Override
  2.  
  3.         public boolean onTouchEvent(MotionEvent event, MapView mapView) {
  4.  
  5.                 if(event.getAction() == MotionEvent.ACTION_DOWN) {
  6.  
  7.                         if (add == true) {
  8.  
  9.                                 this.add = false;
  10.  
  11.                                 this.p = proj.fromPixels((int)event.getX(), (int)event.getY());
  12.  
  13.                             LayoutInflater li = LayoutInflater.from(mContext);
  14.  
  15.                         View view = li.inflate(R.layout.adddialog, null);
  16.  
  17.                         winAlert = new AlertDialog.Builder(mContext)
  18.  
  19.                                 .setIcon(R.drawable.marker)
  20.  
  21.                                 .setTitle("Add a new POI")
  22.  
  23.                                 .setPositiveButton("Save", mOnClickListener)
  24.  
  25.                                 .setNegativeButton("Cancel", mOnClickListener)
  26.  
  27.                                 .setView(view);
  28.  
  29.                         winDialog = winAlert.create();
  30.  
  31.                         winDialog.show();
  32.  
  33.                         }
  34.  
  35.                 }
  36.  
  37.                 return false;
  38.  
  39.         }
Parsed in 0.035 seconds, using GeSHi 1.0.8.4


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

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         OnClickListener mOnClickListener = new OnClickListener() {
  2.  
  3.                 @Override
  4.  
  5.                 public void onClick(DialogInterface dialog, int which) {
  6.  
  7.                         // TODO Auto-generated method stub
  8.  
  9.                         switch(which) {
  10.  
  11.                         case -1:
  12.  
  13.                                 add_dialog_editText = (EditText) winDialog.findViewById(R.id.add_dialog_editText);
  14.  
  15.                                 addLocation(p, "Test", add_dialog_editText.getText().toString());
  16.  
  17.                                 break;
  18.  
  19.                         case -2:
  20.  
  21.                                 dialog.cancel();
  22.  
  23.                                 return;
  24.  
  25.                         }
  26.  
  27.                 }
  28.  
  29.         };
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


My add location method looks like this:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         public void addLocation(GeoPoint p, String title, String desc) {
  2.  
  3.                 OverlayItem overlayItem = new OverlayItem(p, title, desc);
  4.  
  5.                 this.addOverlay(overlayItem);
  6.  
  7.                 mapOverlays.add(this);
  8.  
  9.         }
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


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?
aspekt9
Junior Developer
Junior Developer
 
Posts: 12
Joined: Tue Feb 24, 2009 5:13 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 25 guests