Created
May 10, 2017 17:37
-
-
Save anonymous/34edc1afbdb7e9d10d9adbda63d4cd8c to your computer and use it in GitHub Desktop.
This is how you create the dialogs I showed in the screenshots
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() | |
{ | |
@Override | |
public void onClick(DialogInterface dialog, int which) | |
{ | |
switch (which) | |
{ | |
case DialogInterface.BUTTON_POSITIVE: | |
Log.d("TAG", "User pressed start"); | |
break; | |
case DialogInterface.BUTTON_NEGATIVE: | |
dialog.dismiss(); | |
break; | |
} | |
} | |
}; | |
LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); | |
//Normal AlertDialog | |
new AlertDialog.Builder(this) | |
.setView(inflater.inflate(R.layout.content, null)) | |
.setTitle("Start a new ai game?") | |
.setPositiveButton("Start", dialogClickListener) | |
.setNegativeButton("Close", dialogClickListener); | |
//My AlertDialog | |
new AlertDialog.Builder(this) | |
.setCustomTitle(inflater.inflate(R.layout.title,null)) //The title's TextView's style should be the | |
// same as the the one of the dialog normal AlertDialog's Title Style (see example above) | |
.setView(inflater.inflate(R.layout.content, null)) | |
.setPositiveButton("Start", dialogClickListener) | |
.setNegativeButton("Close", dialogClickListener) | |
.show(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment