【发布时间】:2017-05-16 11:20:26
【问题描述】:
我已经创建了一个悬停对话框来显示给用户,但我想知道是否可以显示一个对话框并且仍然能够在对话框外部执行操作?
提前感谢您的帮助! :D
这是我的 MainActivity:
mMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
@Override
public void onMapClick(LatLng point) {
if(clicked)
{
List<Address> addresses = new ArrayList<>();
try {
addresses = geocoder.getFromLocation(point.latitude, point.longitude,1);
} catch (IOException e) {
e.printStackTrace();
}
android.location.Address address = addresses.get(0);
if (address != null) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < address.getMaxAddressLineIndex(); i++){
sb.append(address.getAddressLine(i) + " ");
}
dialog = new Dialog(context);
dialog.setContentView(R.layout.map_dialog);
dialog.setTitle("IS THIS YOUR LOCATION?");
dialog.setCancelable(true);
dialog.setCanceledOnTouchOutside(false);
text = (TextView) dialog.findViewById(R.id.textLocations);
text.setText(sb.toString());
dialog.show();
Window window = dialog.getWindow();
WindowManager.LayoutParams params = window.getAttributes();
params.gravity = Gravity.BOTTOM;
window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
window.setAttributes(params);
}
mMap.clear();
mMap.addMarker(new MarkerOptions().position(point).draggable(false));
mMap.moveCamera(CameraUpdateFactory.newLatLng(point));
}
}
});
【问题讨论】:
-
@shadygoneinsane 先生,您的回答是正确的,谢谢您的链接。我真的很感激:D
标签: android android-layout android-alertdialog