I just started learning android development, and I want to make a dialog box that looks nice.
this is what I have right now.
I tried looking it up and most of them tell me to make a new shape and add it as the dialog box background, but I don't seem to understand how to set the new shape as the background.
this is my code for the dialog box:
new AlertDialog.Builder(this)
.setTitle(" ")
.setMessage("Congrats! Player " + winner +" wins!")
.setPositiveButton("Play again", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which) {
//my code here
}
})
.setNegativeButton("F", null)
.show();
how do I link my shape background xml to this dialog and how do I make the positive button have a background like in the screenshot?
Edit: question edited because I already tried the method below I don't seem to understand it, besides it has multiple parts (header, footer) which I don't really need my requirement is much more basic.
You can easily set a custom view for your AlertDialog
using setView(View view)
for your dialog.
Your code would be like this:
View view = inflater.inflate(R.layout.your_layout_name, null);
new AlertDialog.Builder(this)
.setView(view)
.create()
.show();