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 29dc4bc..7818735 100644 --- a/app/src/main/java/org/ntlab/amaryllis/client/MyDialogFragment.java +++ b/app/src/main/java/org/ntlab/amaryllis/client/MyDialogFragment.java @@ -26,7 +26,9 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.EditText; import android.widget.RadioGroup; +import android.widget.TextView; import org.ntlab.amaryllis.client.fragment.ListFragment; @@ -37,7 +39,7 @@ public interface DialogFragmentListener{ void onDialogPositiveButtonClicked(); - //public void onOkClicked(Bundle args); + public void onOkClicked(Bundle args); } public interface OnOkClickListener { @@ -81,39 +83,46 @@ } } - +///* @NonNull @Override public Dialog onCreateDialog(@Nullable Bundle savedInstanceState){ - //AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity()) - Dialog dialog = new AlertDialog.Builder(getActivity()) + final EditText editText = new EditText(getActivity()); + editText.setHint("編集できます。"); + 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(); + .setView(editText) + .setPositiveButton("購入する", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + dialogFragmentListener.onDialogPositiveButtonClicked(); + TextView Title = (TextView)getActivity().findViewById(R.id.radioDog); + Title.setText(editText.getText()); + //Title.setText("aaa"); + } + }) + .setNegativeButton("やめる", null); + //.create(); - //return dialogBuilder.create(); - return dialog; + return dialogBuilder.create(); + //return dialog; } +//*/ -/* int mCheckedId; + /* public static MyDialogFragment newInstance() { @@ -135,19 +144,22 @@ } } + */ + + /* @Override public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater inflater = getActivity().getLayoutInflater(); View v = inflater.inflate(R.layout.activity_my_dialog_fragment, null, false); - RadioGroup radioGroup = (RadioGroup) v.findViewById(R.id.radioGroupOptions); + //RadioGroup radioGroup = (RadioGroup) v.findViewById(R.id.radioGroupOptions); - radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { - public void onCheckedChanged(RadioGroup group, int checkedId) { - mCheckedId = checkedId; - } - }); + //radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { + //public void onCheckedChanged(RadioGroup group, int checkedId) { + //mCheckedId = checkedId; + //} + //}); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle("MY DIALOG"); @@ -156,8 +168,9 @@ // 呼び出し元フラグメントのビューを更新 Bundle arg = new Bundle(); arg.putInt("KEY_MYDIALOG", mCheckedId); + // MyFragmentのonOkClickedをコール - mListener.onOkClicked(arg); + //DialogFragmentListener.onOkClicked(arg); } }); builder.setNegativeButton("Cancel", null); @@ -165,13 +178,48 @@ return builder.create(); } +//*/ + + /* + + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + LayoutInflater inflater = requireActivity().getLayoutInflater(); + View v = inflater.inflate(R.layout.activity_my_dialog_fragment, null, false); + //RadioGroup radioGroup = (RadioGroup) v.findViewById(R.id.radioGroupOptions); + + + builder.setView(inflater.inflate(R.layout.activity_my_dialog_fragment, null)); + //radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { + //public void onCheckedChanged(RadioGroup group, int checkedId) { + //mCheckedId = checkedId; + //} + //}); + + + //builder.setTitle("MY DIALOG"); + builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int id) { + // 呼び出し元フラグメントのビューを更新 + //Bundle arg = new Bundle(); + //arg.putInt("KEY_MYDIALOG", mCheckedId); + + // MyFragmentのonOkClickedをコール + //DialogFragmentListener.onOkClicked(arg); + } + }); + builder.setNegativeButton("Cancel", null); + //builder.setView(editText); + builder.setView(v); + return builder.create(); + } + */ - - - - //@Override //public void onCreate(Bundle savedInstanceState) { //super.onCreate(savedInstanceState);