Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8859899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:09:35+00:00 2026-06-14T15:09:35+00:00

Build a dialog I’d like add a listener, but the app crashes.What is wrong?

  • 0

Build a dialog I’d like add a listener, but the app crashes.What is wrong?

private void Info(){

        textview = (TextView) findViewById(R.id.textView1);

        LayoutInflater li = LayoutInflater.from(this);
        View view = li.inflate(R.layout.info, null);

        final AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setView(view).create().show();

        buttonInfo = (Button)findViewById(R.id.buttonInfo);

        buttonInfo.setOnClickListener(new View.OnClickListener() {
              public void onClick(View view) { 

              }
            });
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T15:09:36+00:00Added an answer on June 14, 2026 at 3:09 pm

    I guess that the button is inside your dialog’s layout.

    If it’s the case, try to replace

    buttonInfo = (Button)findViewById(R.id.buttonInfo);
    

    by

    buttonInfo = (Button) view.findViewById(R.id.buttonInfo);
    

    And you need to store the created AlertDialog (instead of the Builder) if you want to dismiss it after:

        final AlertDialog dialog = new AlertDialog.Builder(this).setView(view).show();
    
        buttonInfo = (Button) findViewById(R.id.buttonInfo);
    
        buttonInfo.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                dialog.dismiss();
            }
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to build an app using MonoTouch and MonoTouch.Dialog. I really like
I would like to build a dialog similar to QFileDialog::getExistingDirectory() for which the OK-button
I am about to build my own dialog to notifiy the user the app
I would like to build a generic/re-usable modal dialog that I can use in
i want to build a customized dialog just like the one shown in image:
I want to build a MFC dialog in which I add a simple TabControl
I use the JQuery dialog and from the PHP I can build some add-in
I use modal dialogs. A modal dialog is build up with a mask div,
I need to build app with user messages (dialogs). I've solved this problem by
i build an app where i select a country a city and a street.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.