当对话框已经打开时点击背景布局
问题描述:
我开发了应用程序,我已经集成了。现在我在谷歌地图上设置了这么多的针脚。当我点击任何引脚时,该引脚的细节将显示在一个对话框中。这一切都工作完美。这是images。
问题是: -当我点击一个任何标记,然后对话框打开,但是当我点击第二个标记,然后第一次解雇被解雇。再次点击那个标记对话框将会打开,但是我想打开一个新的对话框,点击任一个。这是可能的,每当我点击任何标记(看图像),那么相关标记(意味着数据)对话框将立即打开?当对话框已经打开时点击背景布局
我尝试了这个dialog.setCanceledOnTouchOutside(true);
,但它只是关闭对话框时,我点击对话框布局的一面。
在此先感谢和帮助将非常感激。
这是对话的方法,我可以当你使用对话框然后View
是在主布局添加,所以你不能在后台点击打开的对话框
Dialog mapMarkerDialog = null;
private void showMapMarkerDialog(Marker marker)
{
try
{
mapMarkerDialog = new Dialog(activity, android.R.style.Theme_Translucent_NoTitleBar);
mapMarkerDialog.setContentView(R.layout.dialog_map_info_window);
mapMarkerDialog.setCanceledOnTouchOutside(true);
RelativeLayout llMapClubDetailTop = (RelativeLayout)mapMarkerDialog.findViewById(R.id.llMapClubDetailTop);
LinearLayout llMapClubDetail = (LinearLayout)mapMarkerDialog.findViewById(R.id.llMapClubDetail);
ImageView imgMapDialogClubImage = (ImageView)mapMarkerDialog.findViewById(R.id.imgMapDialogClubImage);
TextView txtMapDialogClubName = (TextView)mapMarkerDialog.findViewById(R.id.txtMapDialogClubName);
TextView txtMapDialogClubLocation = (TextView)mapMarkerDialog.findViewById(R.id.txtMapDialogClubLocation);
TextView txtMapDialogClubDiscount = (TextView)mapMarkerDialog.findViewById(R.id.txtMapDialogClubDiscount);
llMapClubDetail.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mapMarkerDialog.dismiss();
mapMarkerDialog.cancel();
//start new activity
}
});
mapMarkerDialog.show();
}
catch (Exception e)
{
Log.e(TAG, "***Error while call showMapMarkerDialog() method");
e.printStackTrace();
}
}
答
。在打开新视图之前,您必须先删除View
(对话框)。当你需要做这种类型的功能时,我建议你使用Popup Window,这样你可以显示任意的视图。
请尝试下面的代码。这仅用于显示弹出窗口,只有您可以根据您的要求使用。
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View popuplayoutReject = inflater.inflate(R.layout.your_view, null);
final PopupWindow popUpReject = new PopupWindow(popuplayoutReject, WindowManager.LayoutParams.FILL_PARENT,
WindowManager.LayoutParams.WRAP_CONTENT, false);
popUpReject.setOutsideTouchable(true);
popUpReject.showAtLocation(popuplayoutReject, Gravity.BOTTOM, 0, 0);
+0
它的作品魅力。你能再详细介绍一下吗? – Ninja
而不是对话框使用ViewGroup来显示这些信息。您可以使用可见性属性显示和隐藏ViewGroup。 –
@SureshKumar感谢您的回复,但您能否提供更多关于'ViewGroup'的信息? – Ninja
使用'弹出窗口'而不是对话框。 – Shailesh