How to change the Activity when clicking on an option in the AlertDialog menu?

0

I have the following problem, I have a method that is called, when the person clicks a button, and SAVE, (onLongClickListener) will appear an alert with several options. 1st Option is Cancel the Table, 2nd View requests, and 3rd Call another activity. It happens, that gives error when I click on the third option, where would be my Intent, calling another Activity.

Note: The initialization of the other activity has no error, since I can access it by other buttons using the same method Intent intent = new Intent ();

private AlertDialog opcoes;
CharSequence op[] = new CharSequence[] {"Cancelar Mesa", "Ver Pedidos", "Acrescentar/Alterar Pedido", "Teste"};
private void opcoesMesas(final View v) {
    //Cria o gerador do AlertDialog
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    // define o titulo
    builder.setTitle("Escolha a Opção desejada: ");
    //define a mensagem
    //builder.setMessage("Deseja cancelar essa mesa?");
    //define um botão como positivo
    builder.setItems(op, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
                switch(i){
                    case 0:
                        ConfirmacaoDeCancelamento(v);
                        break;
                    case 1:
                        exibindoPedidosDasMesas(v);
                        break;

                    case 2:
                        openPedidos();
                        break;

                    case 3:
                        break;

                    default:
                }


        }
    });
    builder.show();
}


private void openPedidos(){
    startActivity(new Intent(getBaseContext(),pedidos.class));
}

In case 2: I already tried to put the Direct Intent, it also does not work. And it recognizes that it was clicked on the third option, because I already put a Toat to inform me if it arrived in Case 2, and it worked.

Help me, I just need to call another screen, by clicking on Case 2.

    
asked by anonymous 02.12.2015 / 21:25

1 answer

2

Before going to the next activity call the method dismiss() of the dialog and then call the method openPedidos()

    
04.12.2015 / 01:49