Newer
Older
NemophilaClient / app / src / main / java / com / example / nemophila / RequestingDialogFragment.java
package com.example.nemophila;

import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;

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

public class RequestingDialogFragment extends DialogFragment {
    private RequestingActivity requestingActivity;

    public RequestingDialogFragment(RequestingActivity requestingActivity) {
        this.requestingActivity = requestingActivity;
    }

    @NonNull
    @Override
    public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {

        String message = getArguments().getString("message", "");

        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setTitle("フレンド申請")
                .setMessage(message + "さんに申請しますか?")
                .setPositiveButton("申請を送る", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        // ボタンを押した時にフレンド申請を送る
                        requestingActivity.putRequesting();
                    }
                })
                .setNegativeButton("キャンセル", null);
        return builder.create();
    }

}