i want to create Alert Dialog with custom title but without any XML in fact i want to create class that extends Alert Dialog
Asked
Active
Viewed 122 times
-1
-
Have a look at [this question](https://stackoverflow.com/questions/7825720/extending-alertdialogs-in-android-where-to-find-examples-how-to-get-title-and), you can apparently extend the `AlertDialog.Builder` class... – deHaar Sep 05 '18 at 11:31
-
AlertDialog alert = new AlertDialog.Builder(MainActivity.this).create(); alert.setTitle("TITLE"); alert.setMessage("Error"); alert.setButton(DialogInterface.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { finish(); } }); alert.show(); – Bhuvaneshwaran Vellingiri Sep 05 '18 at 11:45
1 Answers
1
You could call setCustomTitle()
on a progmatically confirmed TextView.
For example:
TextView tv = new TextView(this);
tv.setText("Title Here");
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setCustomTitle(tv);

Shai
- 101
- 1
- 11