BottomNavigationView does not work on first click

0

I have a problem with my advance menu, it does not work when I click the first time, it is necessary to double click to perform the action

bottomNavigationView.setOnNavigationItemReselectedListener(new BottomNavigationView.OnNavigationItemReselectedListener() {
@Override
public void onNavigationItemReselected(@NonNull MenuItem item) {
    switch (item.getItemId()) {
        case R.id.menuAvancar:
            if (camposObrigatoriosWS()) {

                DatabaseHelper db = new DatabaseHelper(getApplicationContext());
                ClienteDao clienteDao = new ClienteDao();
                clienteDao.buscarUltimoID(db);
                //Verifica se quer continuar cadasto de pacote ou somente cliente
                AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(CadastrarClienteActivity.this);
                LayoutInflater inflater = getLayoutInflater();
                View dialogView = inflater.inflate(R.layout.item_dialog_cadastro_cliente, null);
                dialogBuilder.setView(dialogView);

                iniciarComponentesDialog(dialogView);

                dialogBuilder.create().show();

                btnContinuar.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        inserirCliente("N");
                        Intent intent = new Intent(CadastrarClienteActivity.this, EscolherPacoteActivity.class);
                        startActivity(intent);
                    }
                });

                btnCadastrar.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        inserirCliente("S");
                        Intent intent = new Intent(CadastrarClienteActivity.this, CaixaDeEntradaActivity.class);
                        startActivity(intent);
                    }
                });
            } else {
                toastUtil.exibirToastCurtoPrazo(CadastrarClienteActivity.this, "Campos obrigatorios não informado");
            }
            break;
    
asked by anonymous 13.12.2017 / 11:12

1 answer

3

This is because you are using setOnNavigationItemReselectedListener . As the name already says, Reselect , it is only called when the item is already selected and is clicked again.

For your case, use setOnNavigationItemSelectedListener .

    
13.12.2017 / 13:47