Last active
April 11, 2016 05:45
-
-
Save booknara/211608789864518653dc to your computer and use it in GitHub Desktop.
Android AlertDialog Template code
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
/** | |
* Android Simple AlertDialog BoilerPlate Code | |
* | |
* @author Daehee Han (bookdori81@gmail.com) | |
* @since 05/15/2014 | |
* @version 1.0.0 | |
* | |
*/ | |
import android.app.Activity; | |
import android.os.Bundle; | |
import android.app.AlertDialog; | |
import android.content.DialogInterface; | |
public class SimpleAlertDialog extends Activity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
AlertDialog.Builder builder = new AlertDialog.Builder(getContext()) | |
.setTitle(R.string.title) | |
.setMessage(R.string.msg) | |
.setCancelable(false) | |
.setPositiveButton(R.string.lbl_yes, new DialogInterface.OnClickListener() { | |
@Override | |
public void onClick(DialogInterface dialog, int which) { | |
dialog.dismiss(); | |
} | |
}) | |
.setNeutralButton(R.string.lbl_not_now, new DialogInterface.OnClickListener() { | |
@Override | |
public void onClick(DialogInterface dialog, int which) { | |
dialog.dismiss(); | |
} | |
}) | |
.setNegativeButton(R.string.lbl_no, new DialogInterface.OnClickListener() { | |
@Override | |
public void onClick(DialogInterface dialog, int which) { | |
dialog.dismiss(); | |
} | |
}); | |
builder.show(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Additional example to display html link in the dialog view.