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 8236437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:08:01+00:00 2026-06-07T19:08:01+00:00

We have creating two custom dialog box, one is about and another one is

  • 0

We have creating two custom dialog box, one is about and another one is alert. When i choose alternately in the tow custom dialog box at that time the button is not working.

Sample code

AlertDialog.Builder builder;
Context mContext;
LayoutInflater inflater;
View layout;
Dialog dialog;
@Override
protected Dialog onCreateDialog( int id ) 
{ 
    switch ( id ) 
    {
        case 1:
            builder = null;
            mContext = this;
            inflater = ( LayoutInflater ) mContext.getSystemService( LAYOUT_INFLATER_SERVICE );
            layout = inflater.inflate( R.layout.alert_page, ( ViewGroup ) findViewById( R.id.alert_Root ) );
            Button alertUser = ( Button ) layout.findViewById( R.id.alert_Submit );
            alertUser.setOnClickListener( new View.OnClickListener()
            {
                public void onClick( View v )
                {
                    try
                    {
                        dialog.dismiss();
                    }
                    catch ( Exception e ) 
                    {
                        Toast.makeText( getBaseContext(), e.getMessage(), Toast.LENGTH_SHORT ).show();
                    }
                }
            });
            builder = new AlertDialog.Builder( mContext );
            builder.setView( layout );
            dialog = builder.create();
            dialog.show();
            break;

        case 2:
            builder = null;
            mContext = this;
            inflater = ( LayoutInflater ) mContext.getSystemService( LAYOUT_INFLATER_SERVICE );
            layout = inflater.inflate( R.layout.about_page, ( ViewGroup ) findViewById( R.id.about_Root ) );
            Button aboutUser = ( Button ) layout.findViewById( R.id.about_Submit );
            aboutUser.setOnClickListener( new View.OnClickListener()
            {
                public void onClick( View v )
                {
                    Log.e("About","About");
                    try
                    {
                        Log.e("About1","About");
                        dialog.dismiss();
                    }
                    catch ( Exception e ) 
                    {
                        Log.e("About","About12");
                        Toast.makeText( getBaseContext(), e.getMessage(), Toast.LENGTH_SHORT ).show();
                    }
                }
            });
            builder = new AlertDialog.Builder( mContext );
            builder.setView( layout );
            dialog = builder.create();
            dialog.show();
            break;
    }
    return dialog;
}

For example i am using two button. First button is called case 1 and second button is called case 2.

I am selected First button to access case 1 and then selected custom dialog box alertUser button successfully Exit the dialog box.

Immediately I am selected Second button to access case 2 and then select custom dialog box aboutUser button successfully Exit the dialog box.

After Immediately I am selected First button to access case 1 and then select custom dialog box alertUser button Now the dialog box does not exist (button is now not working).

Where i am mistaken code. How do solved this problem.

Thanks in advance.

  • 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-07T19:08:03+00:00Added an answer on June 7, 2026 at 7:08 pm

    you are calling dialog as showDialog(int). remove this line dialog.show(); in your onCreateDialog

    and call dismissDialog(int) to dismiss the dialog instead of dialog.dismiss();

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom dialog box that collects two strings from the user. I
I'm creating a WP theme that will have two sections midway down the page.
I have a module that is used by creating a custom class loader. The
I have need to use one of two custom file readers classes; one to
I'm creating an iPad app, and I have two classes: NWRootViewController : UITableViewController and
I'm creating an application which works on Froyo until Jelly Beans. I have two
I am working on creating .NET TBB for Tridion 2011 SP1. I have two
I have been creating a peer to peer connection for a new game, that
I have mastered creating custom data types and adding fields with CCK. Then I
I have problems creating a custom query. This is what entities: @Entity public class

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.