There is an error when I call the intent startActivity (new Intent (this, Advogado1.class)), How should I proceed to properly call this Intent
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Atenção");
alert.setMessage("Digite o Numero da OAB");
// Set an EditText view to get user input
final EditText input = new EditText(this);
alert.setView(input);
alert.setPositiveButton("Ok",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
int oab = Integer.parseInt(input.getText()
.toString());
// Do something with value!
if (oab == 1) {
startActivity(new Intent(this, Advogado1.class));
}
}
});
alert.setNegativeButton("Cancelar",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
// Canceled.
}
});
alert.show();
The call to,
should not use ‘this’, it should use,
because
thisrefers to the anonymous class extendingDialogInterface.OnClickListener, and not yourActivityclass. The Intent needs the caller class to be an instance of Activity.