Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

150
Visualizações
Alert Dialog builder doesn't have dismiss or cancel method

I know that there are lot of solutions currently to this question, but i couldn't solve with any of them. Actually i created a imageView and i set a listener to that imageView, i also created a custom builder to create my own alertDialog, what i need is to close the dialog when i click on the imageView so i did something like this:

final AlertDialog.Builder builder = new AlertDialog.Builder(Friends.this);
LayoutInflater inflater = Friends.this.getLayoutInflater();
                final View dialogView = inflater.inflate(R.layout.custom_builder, null);
close.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                    }
                });
 builder.show();

this is just part of my code, the builder.show is working fine, the close is the name of my imageView.

Thank you very much guys.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

you have to add builder.create() method for dismiss dialog. get an instance and dismiss it.

final AlertDialog.Builder builder = new AlertDialog.Builder(Friends.this);
    AlertDialog dialogInstance=builder.create();
    LayoutInflater inflater = Friends.this.getLayoutInflater();
                    final View dialogView = inflater.inflate(R.layout.custom_builder, null);
                        close.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                        dialogInstance.dismiss()
                        }
                    });
     builder.show();

happy coding :)

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda