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

  • Home
  • SEARCH
  • 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 6699587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:42:47+00:00 2026-05-26T06:42:47+00:00

i am having an custom alert view which pop ups on a button click

  • 0

i am having an custom alert view which pop ups on a button click event.all the things are going fine.but the problem is:
if user clicks outside alert dialog it disappear.i want to restrict user for clicking out side.I am giving him the choice of cancel/cross button to close alert dialog.
so how to restrict user clicking outside the alert box?
code:

the code in onCreate for button click where i am calling show dialog:

final Button cdButton = (Button) findViewById(R.id.denonCdImage);
    cdButton.setOnClickListener(new Button.OnClickListener(){   
        public void onClick(View v) 
        {
            showDialog(CD_CATG_ID);
        }
    });



protected Dialog onCreateDialog(int id) {   

    AlertDialog.Builder builder;   
    Context mContext = this;   
    LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE);   
    View layout = inflater.inflate(R.layout.categorydialog,(ViewGroup) findViewById(R.id.layout_root));   
    GridView gridview = (GridView)layout.findViewById(R.id.gridview);   
    gridview.setAdapter(new ImageAdapter(this)); 
    /** Check the id for the device type for image tobe change */
    switch(id) {   
    case 1 :   // for the cd image 
        gridview.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view,final int position, long id) {   
                Toast.makeText(view.getContext(), "Image selected for CD", 3000).show();
                cdImageId = getImageId(position);
                int elementId = getApplicationContext().getResources().getIdentifier(cdImageId, "drawable", getPackageName());
                cdImageView.setImageResource(elementId);

                Log.d("CdImageid", ""+cdImageId);
                closeDialog(view);
            }   
        });
        builder = new AlertDialog.Builder(mContext);   
        builder.setView(layout);   
        dialog = builder.create();   
        break;  
default:   
        dialog = null;   
    }

    /** onclick listner for the close button */
    ImageView close = (ImageView) layout.findViewById(R.id.close);
    close.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v){
            dialog.dismiss();
        }
    });

    return dialog;   
}  

any suggestions?
thanks!

  • 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-26T06:42:47+00:00Added an answer on May 26, 2026 at 6:42 am

    There are two methods concerning this behaviour: setCancelable() and setCanceledOnTouchOutside() as you can see in the reference.

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

Sidebar

Related Questions

I am having a problem where I dispatch a custom event but the listener
I've been learning Mootools, but I'm having problems firing custom events. I'm sure it
I am having a custom 'tableview' implementation. I am implementing a feature which I
I seem to be having an issue delegating a custom event to a set
Having searched for a way to enforce immutability of custom types and not having
Having a bit of trouble using the List.Find with a custom predicate i have
I'm having trouble with a custom tag:- org.apache.jasper.JasperException: /custom_tags.jsp(1,0) Unable to find setter method
I am having problems using my custom class with a std::map. The class dynamically
I am having trouble animating a custom UITableView section header. The goal was to
I'm having trouble trying to attach a custom tracking participant in workflow foundation 4.0.

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.