Answer the question
In order to leave comments, you need to log in
How to add what the user entered into AlertDialog in InfoWindow in GoogleMap?
After clicking the "OK" button in the AlertDialog window, my application crashes. I have three different buttons for markers (the only difference is that the user can select an icon) and on one I wrote the following code:
fab2.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Toast.makeText(PersonMapActivity.this, "Маркер выбран", Toast.LENGTH_SHORT).show();
GeoFire geofire = new GeoFire(PersonDatabaseRef);
geofire.setLocation(personId, new GeoLocation(lastLocation.getLatitude(), lastLocation.getLongitude()));
PersonPostion = new LatLng(lastLocation.getLatitude(),lastLocation.getLongitude());
BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(R.drawable.oxygen);
LayoutInflater li = LayoutInflater.from(context);
View promptsView = li.inflate(R.layout.android_user_input_dialog, null);
final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
context);
// set prompts.xml to alertdialog builder
alertDialogBuilder.setView(promptsView);
final EditText userInput = (EditText) promptsView
.findViewById(R.id.editTextDialogUserInput);
// set dialog message
alertDialogBuilder
.setCancelable(false)
.setPositiveButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
// get user input and set it to result
// edit text
result.setText(userInput.getText());
}
})
.setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
dialog.cancel();
}
});
// create alert dialog
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
MarkerOptions markerOptions = new MarkerOptions().position(PersonPostion)
.snippet(String.valueOf(result)).icon(icon)
.title("ss");
mMap.addMarker(markerOptions);
}
});
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question