我正在xamarin中构建一个应用程序,我试图从另一个对话框中弹出AleartDialog并且它成功发生但问题是:
当第二个对话框打开时,前一个对话框变得不可见,当我返回时,它会自动弹出。
下图可以使要求更加清晰
图像1是我想要的,但它就像图像2和图像3
下面的是我的DialogInterface类
public class DialogBuilder : DialogFragment {
public static DialogBuilder NewInstance(bool showPrimary) {
DialogBuilder fragment = new DialogBuilder { Arguments = new Bundle() };
fragment.Arguments.PutBoolean("boolean", showPrimary);
return fragment;
}
public override void OnCreate(Bundle savedInstanceState) {
base.OnCreate(savedInstanceState);
// Create your fragment here
}
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Use this to return your custom view for this Fragment
// bool showPrimaryLayout = Arguments.GetBoolean("boolean");
View view = null;
bool showPrimaryLayout = Arguments.GetBoolean("boolean");
InputMethodManager inputManager = (InputMethodManager)Activity.GetSystemService(Context.InputMethodService);
var currentFocus = Activity.CurrentFocus;
if (currentFocus != null) {
inputManager.HideSoftInputFromWindow(currentFocus.WindowToken, HideSoftInputFlags.none);
}
if (showPrimaryLayout) {
view = inflater.Inflate(Resource.Layout.dialog_edit_schedule_party, container, false);
var button_add_hostess = view.FindViewById<Button>(Resource.Id.btn_add_hostess);
button_add_hostess.Click += (s, e) => ShowDialog(false);
}
else {
view = inflater.Inflate(Resource.Layout.fragment_add_hostess_dialog, container, false);
}
return view;
}
public void ShowDialog(bool isPrimary) {
FragmentTransaction transction = FragmentManager.BeginTransaction();
//Remove fragment else it will crash as it is already added to backstack
Fragment prev = FragmentManager.FindFragmentByTag("dialog");
if (prev != null) {
transction.Remove(prev);
}
transction.AddToBackStack(null);
DialogBuilder builder = NewInstance(isPrimary);
builder.Show(transction, "dialog");
}
}
}
在我的活动类中实现
private void popUpDialog() {
FragmentTransaction ft = FragmentManager.BeginTransaction();
//Remove fragment else it will crash as it is already added to backstack
Fragment prev = FragmentManager.FindFragmentByTag("dialog");
if (prev != null) {
ft.Remove(prev);
}
ft.AddToBackStack(null);
// Create and show the dialog.
DialogBuilder dialog = DialogBuilder.NewInstance(true);
dialog.Cancelable = false;
//Add fragment
dialog.Show(ft, "dialog");
}
感谢任何帮助。
答案 0 :(得分:0)
问题在于以下代码
convert $(gls -v "$file"*.jpeg) "$file".pdf
对于这两个对话框,发送的字符串标签是相同的,这导致隐藏了之前打开的对话框。
解决方案:
dialog.Show(ft,“dialog_one”); //第一个对话框。
dialog.Show(ft,“dialog_two”); //第二个