I’m working with android and I want to make an event on AlertDialog button. I want to change the text on the button dynamically, this is my code
AlertDialog.Builder alert = new AlertDialog.Builder(Soto_Betawi.this);
alert.setTitle("Payment");
alert.setMessage("Total Price : Rp. " + total);
final EditText input = new EditText(Soto_Betawi.this);
alert.setView(input);
alert.setPositiveButton("Change Due", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int which)
{
cash = Integer.parseInt(input.getText().toString());
change = cash - total;
//I want to set a text from the operation above in a text
}
});
alert.setNegativeButton("Close", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int which)
{
}
});
alert.setCancelable(true);
alert.create().show();
Instead of using AlertDialog, you can use Activity with Dialog theme and create your own layout. So that you can simply change the text with
myButton.setText("your text");