Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@codingwithsara
Created September 8, 2019 13:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codingwithsara/7ad9c243d65a22eefd899005af28cdfb to your computer and use it in GitHub Desktop.
Save codingwithsara/7ad9c243d65a22eefd899005af28cdfb to your computer and use it in GitHub Desktop.
AlertDialog Customize 4
// タイトル
TextView titleView = new TextView(this);
titleView.setText("タイトル");
titleView.setTextSize(24);
titleView.setTextColor(Color.WHITE);
titleView.setBackgroundColor(getResources().getColor(R.color.alertBlue));
titleView.setPadding(20, 20, 20, 20);
titleView.setGravity(Gravity.CENTER);
// メッセージ
TextView msgView = new TextView(this);
msgView.setText("ここにメッセージを入力します。ここにメッセージを入力します。ここにメッセージを入力します。");
msgView.setTextSize(16);
msgView.setTextColor(Color.BLACK);
msgView.setPadding(20, 20, 40, 20);
AlertDialog dialog = new AlertDialog.Builder(this)
.setCustomTitle(titleView)
.setView(msgView)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// OK が押された時の処理を書く
}
})
.show();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment