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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:47:12+00:00 2026-05-27T22:47:12+00:00

I am a new to android development and need help. Please explain in detail

  • 0

I am a new to android development and need help. Please explain in detail and not just supply me with an answer that would be ideal.

My issue: I created a dialog box for my app and well it displays great, it dims the app and just opens the box but I am having issues closing it. If someone wanted to exit out of it, they would have to press the back arrow button. Yeah, this is not hard-work, but I would like my app to be nicely done and clean-cut. So I was wondering if there was a way to put an “X” at the top right corner to exit the dialog box?

If someone could add on to my code that would be perfect.Like I said, I am new to this and someone telling me just add this. I would not know where to add that code to.

My Code:

 @Override
   protected void onPause() {
      // TODO Auto-generated method stub
      super.onPause();
   }

   public boolean onCreateOptionsMenu(Menu menu){
   super.onCreateOptionsMenu(menu);
   MenuInflater library = getMenuInflater();
   library.inflate(R.menu.main_menu, menu);
   return true;
}

   public boolean onOptionsItemSelected(MenuItem item){
      switch (item.getItemId()){
      case R.id.menuAus:
         startActivity(new Intent("com.tester.web.AUS"));
         return true;
      }
      return false;
   }
  • 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-05-27T22:47:12+00:00Added an answer on May 27, 2026 at 10:47 pm

    You can also use a close button (BUTTON_NEGATIVE) if you like within the Dialog Box.

    Also check out this answer: How to display a Yes/No dialog box in Android?

    You should be easily able to customize that code as per your requirements. Good Luck!

    Edit:

    Put this line in OnCreate()

    Context mcontext=this;

    Now use this variable in following code

    final AlertDialog.Builder alert = new AlertDialog.Builder(mcontext);  
    alert.setTitle(title);                       
    alert.setMessage(description);             
    alert.setNegativeButton("Ok",new DialogInterface.OnClickListener()
    

    //You can also run this without the overiding the method

    {
                  @Override                         
                   public void onClick(DialogInterface dialog, int which)               
                   {
                       dialog.cancel();
        });   
                              alert.show(); 
    

    Try this code.. It is running successfully..you might need to customize it a bit as per your needs..

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

Sidebar

Related Questions

I'm just getting started with android development and I need help with background images.
Extreme Android developer newbie here...well, new to Android development, not development in general. I
I am new to Android Development. For my project, I need to use REST
i am new to both android and OpenGL development i try to do just
I am new to Android development. Please excuse me If my question is very
I am new to Android development with Phonegap and just got through these two
I'm very new to Android development and can't find the answer to this. I
I am new to Android development and am not sure of the best way
I am new to both openGL and android development so please forgive me if
I am relatively new to Android development. My requirement is such that I have

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.