Alert Dialog Two Buttons
try this
public void showDialog(Activity activity, String title, CharSequence message) {
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
if (title != null) builder.setTitle(title);
builder.setMessage(message);
builder.setPositiveButton("OK", null);
builder.setNegativeButton("Cancel", null);
builder.show();
}
Adding Buttons
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Are you sure you want to exit?")
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
MyActivity.this.finish();
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
This should do the trick for you:
Button share = (Button) findViewById(R.id.btn_share);
share.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// call some other methods before that I guess...
AlertDialog alertDialog = new AlertDialog.Builder(PasswActivity.this).create(); //Read Update
alertDialog.setTitle("Uprgade");
alertDialog.setMessage("Upgrade Text Here");
alertDialog.setButton( Dialog.BUTTON_POSITIVE, "Upgrade", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
});
alertDialog.setButton( Dialog.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
});
alertDialog.show(); //<-- See This!
}
});