Skip to content

Instantly share code, notes, and snippets.

@codeforfun-jp
Created November 10, 2023 13:01
Show Gist options
  • Save codeforfun-jp/f222e92d4542e9ecaee2b49f4055bf7b to your computer and use it in GitHub Desktop.
Save codeforfun-jp/f222e92d4542e9ecaee2b49f4055bf7b to your computer and use it in GitHub Desktop.
How to create dialog series 1 basic - java 1
package com.example.sample;
import android.app.Dialog;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.DialogFragment;
public class MyDialogFragment extends DialogFragment {
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
return new AlertDialog.Builder(requireActivity())
.setTitle("タイトル")
.setMessage("ここにメッセージを入力します")
.setPositiveButton("OK", (dialog, id) -> {
// このボタンを押した時の処理を書きます。
})
.setNegativeButton("キャンセル", null)
.setNeutralButton("あとで", null)
.create();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment