package jp.gihyo.mitoma.android.p011login;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;

public class MyDialog extends DialogFragment {
    @NonNull
    @Override
    public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
        AlertDialog.Builder builder = new AlertDialog.Builder(requireActivity());
        TextView tvResult = requireActivity().findViewById(R.id.tvResult);
        String message = tvResult.getText().toString();
        builder.setTitle("ダイアログ表示");
        builder.setMessage(message);
        builder.setPositiveButton("OK",new MyDialogOkListener());
        Dialog dialog = builder.create();
        return dialog;
    }

    private class MyDialogOkListener implements DialogInterface.OnClickListener{
        public void onClick(DialogInterface dialog,int buttonNo){
            Toast.makeText(requireContext(),"ＯＫボタンON",Toast.LENGTH_LONG).show();
        }
    }


}
