I created a pop up to confirm a package and when the user selects the "confirm" button it should take the user to another activity but it is not working properly.
Here is my code:
switch (v.getId()) {
case R.id.button_solicitar:
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setCancelable(true);
builder.setTitle("Confirmación");
builder.setMessage("¿Deseas solicitar " + sum + " toallas con un total de $" + tot1 + " pesos?");
builder.setPositiveButton("Confirmar",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(Paquetes.this, "¡Tu pedido ha sido solicitado!", Toast.LENGTH_LONG).show();
startActivity(new Intent(this, Casa.class));
}
});
builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
AlertDialog dialog = builder.create();
dialog.show();
break;