Currently when the user opens my app, an AlertDialog opens, asking them if they would like to upgrade to the pro version.
I need to add a CheckBox to the AlertDialog that will make the app no longer show the AlertDialog when the user opens the app.
Here is what I have for the AlertDialog now:
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(" MY_TEXT");
builder.setMessage(" MY_TEXT ")
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Uri uri = Uri.parse("market://details?id=MY_APP_PACKAGE");
Intent intent = new Intent (Intent.ACTION_VIEW, uri);
startActivity(intent); }
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
}).show();
How do I add a CheckBox to the AlertDialog that will make the app no longer show the AlertDialog when the user opens the app?
You have to use the method
setView(View)on theAlertDialog.Builderobject. This will put the passed inViewbetween the message area and buttons. Simply inflate aViewwith aCheckBoxand pass that in. Here’s an example:checkbox.xml
Code in your Activity