0
I’m trying to make a alertdialog but it’s giving error:
06-08 13:04:38.318 22518-22518/realsysten.com.br.sigarestaurante E/AndroidRuntime: FATAL EXCEPTION: main
Process: realsysten.com.br.sigarestaurante, PID: 22518
java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.support.v7.app.AppCompatDelegateImplV7.createSubDecor(AppCompatDelegateImplV7.java:340)
at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:309)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:273)
at android.support.v7.app.AppCompatDialog.setContentView(AppCompatDialog.java:80)
at android.support.v7.app.AlertController.installContent(AlertController.java:214)
at android.support.v7.app.AlertDialog.onCreate(AlertDialog.java:256)
at android.app.Dialog.dispatchOnCreate(Dialog.java:394)
at android.app.Dialog.show(Dialog.java:295)
at realsysten.com.br.sigarestaurante.AlterarAtendenteActivity$3.onClick(AlterarAtendenteActivity.java:100)
at android.view.View.performClick(View.java:5198)
at android.view.View$PerformClick.run(View.java:21147)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Class with the dialog:
public class AlterarAtendenteActivity extends AppCompatActivity {
EditText nome;
EditText senha;
Button confirmaAltera;
Button cancelaAltera;
Button deletaAt;
Cursor cursor;
BancoController crud;
String codigo;
private AlertDialog alerta;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.alterar_atendente);
codigo = this.getIntent().getStringExtra("codigo");
crud = new BancoController(getBaseContext());
nome = (EditText) findViewById(R.id.edtAltNome);
senha = (EditText) findViewById(R.id.edtAltSenha);
confirmaAltera = (Button) findViewById(R.id.btnAlterarAtendente);
cancelaAltera = (Button) findViewById(R.id.btnCancelarAltAtend);
deletaAt = (Button) findViewById(R.id.btnDeletarAtendente);
cursor = crud.carregarAtendenteId(Integer.parseInt(codigo));
nome.setText(cursor.getString(cursor.getColumnIndexOrThrow(CriaBanco.getAtNome())));
senha.setText(cursor.getString(cursor.getColumnIndexOrThrow(CriaBanco.getAtSenha())));
confirmaAltera.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
crud.alteraAtendente(Integer.parseInt(codigo), nome.getText().toString(),
senha.getText().toString());
Intent i = new Intent(AlterarAtendenteActivity.this, LoginAtendActivity.class);
LoginAtendActivity.op = 1;
startActivity(i);
finish();
}
});
cancelaAltera.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(AlterarAtendenteActivity.this, OpcoesActivity.class);
LoginAtendActivity.op = 1;
startActivity(i);
finish();
}
});
deletaAt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(getBaseContext());
builder.setTitle("Alerta");
builder.setMessage("Deseja realmente excluir o atendente: " + nome);
builder.setPositiveButton("Sim", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
crud.deletaAtendente(Integer.parseInt(codigo));
Intent i = new Intent(AlterarAtendenteActivity.this, LoginAtendActivity.class);
LoginAtendActivity.op = 1;
Toast.makeText(AlterarAtendenteActivity.this, "Atendente deletado",
Toast.LENGTH_LONG);
startActivity(i);
finish();
}
});
builder.setNegativeButton("Não", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(AlterarAtendenteActivity.this, "Atendente não deletado",
Toast.LENGTH_LONG);
}
});
alerta = builder.create();
alerta.show();
}
});
}
}
someone can help me?
failed to put the style in the vlw manifest
– Taha tsu