diff --git a/app/src/main/java/org/ntlab/amaryllis/client/MyDialogFragment.java b/app/src/main/java/org/ntlab/amaryllis/client/MyDialogFragment.java index e814929..29dc4bc 100644 --- a/app/src/main/java/org/ntlab/amaryllis/client/MyDialogFragment.java +++ b/app/src/main/java/org/ntlab/amaryllis/client/MyDialogFragment.java @@ -22,6 +22,7 @@ import androidx.fragment.app.DialogFragment; import androidx.fragment.app.Fragment; + import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -32,44 +33,43 @@ public class MyDialogFragment extends DialogFragment { - private DialogFragmentListener dialogFragmentListener; + + public interface DialogFragmentListener{ void onDialogPositiveButtonClicked(); + //public void onOkClicked(Bundle args); } + public interface OnOkClickListener { + //public void onOkClicked(Bundle args); + } + + private DialogFragmentListener dialogFragmentListener; + public MyDialogFragment newInstance(DialogFragmentListener dialogFragmentListener){ this.dialogFragmentListener = dialogFragmentListener; return new MyDialogFragment(); } - @NonNull - @Override - public Dialog onCreateDialog(@Nullable Bundle savedInstanceState){ - AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity()) - .setTitle("購入") - .setMessage("購入しますか?") - .setPositiveButton("購入する", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - dialogFragmentListener.onDialogPositiveButtonClicked(); - } - }) - .setNegativeButton("やめる", null); - - return dialogBuilder.create(); - } - public MyDialogFragment newInstance(Fragment fragment){ + public static MyDialogFragment newInstance(Bundle bundle,Fragment fragment){ MyDialogFragment instance = new MyDialogFragment(); + instance.setArguments(bundle); instance.setTargetFragment(fragment, 0); return instance; } + + @Override public void onAttach(Context context) { super.onAttach(context); + //public void onAttach(Activity activity) { + //super.onAttach(activity); + + //System.out.printf("aaaaaaaaaaa"); Fragment targetFragment = this.getTargetFragment(); try{ @@ -83,6 +83,32 @@ + @NonNull + @Override + public Dialog onCreateDialog(@Nullable Bundle savedInstanceState){ + //AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity()) + Dialog dialog = new AlertDialog.Builder(getActivity()) + .setTitle("購入") + .setMessage("購入しますか?") + //.setPositiveButton("購入する", new DialogInterface.OnClickListener() { + //@Override + //public void onClick(DialogInterface dialog, int which) { + //dialogFragmentListener.onDialogPositiveButtonClicked(); + //} + //}) + //.setNegativeButton("やめる", null); + .create(); + + //return dialogBuilder.create(); + return dialog; + } + + + + + + + /*