| Register | Members List | Social Groups | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||||||
|
|
| General Dev Discussions, How to, Guides and FAQ Discuss Android Development How to and Guides here. No commercial posts please! |
![]() |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
I have a program that uses a Map View and when they click a menu item it prompts them (in a Dialog box) to enter a name and then press enter. Once they press enter I want to take what was received in the Text Edit in the dialog box and display it in a toast. However, it seems that I just get a blank toast when I try this. Here's some code:
I use getters and setters to accomplish this: Code:
public void setText(String text) {
test = text;
}
public String getText() {
return test;
}
Code:
btn_save = (Button) findViewById(R.id.btn_save);
btn_save.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
setText(add_dialog_editText.getText().toString());
dismiss();
}
});
Code:
POIDialog d = new POIDialog(mContext);
d.setTitle("Add a POI");
d.setContentView(R.layout.adddialog);
d.show();
|
| Ads | ||
|
|
|
#2
|
|||
|
|||
|
I think I know the issue, after I call d.show() to show the dialog, it's not waiting for interaction from the user and it just jumps right down to addLocation() which is why it's not showing up. How can I make the application wait for input received from the user before continuing?
|
|
#3
|
|||
|
|||
|
Okay so just an update, I figured out how to do this however I have a new problem...
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: Code:
@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;
}
Code:
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;
}
}
};
Code:
public void addLocation(GeoPoint p, String title, String desc) {
OverlayItem overlayItem = new OverlayItem(p, title, desc);
this.addOverlay(overlayItem);
mapOverlays.add(this);
}
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? |
|
#4
|
|||
|
|||
|
Hello,
I am new to android, can you please help me by posting a sample code to show a Linear layout as popup, on click of some button. Please it is very urgent.........coud not find any proper sample for it. Thanks Nitin |
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
| Ads | ||
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to send contact information | brie987 | Android OS Discussions | 2 | 05-04-2009 07:18 PM |
| information on flash | jujufisticuffs | General Dev Discussions, How to, Guides and FAQ | 2 | 02-24-2009 05:06 PM |
| Pictures of the OTA update & new USB connection dialog | mixpix405 | HTC Handsets | 12 | 11-06-2008 12:40 PM |
| Auto retrieval of email issues?? | Gthmcty1 | HTC Handsets | 6 | 10-28-2008 04:05 AM |
| Google Talk Presence Information | jaroque | HTC Handsets | 0 | 10-22-2008 02:53 PM |