Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

154
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!