how to restrict user by clicking outside the alert box in android?
<p>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:</p>

<p>the code in onCreate for button click where i am calling show dialog:  </p>

<pre><code>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&lt;?&gt; 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;   
}  
</code></pre>

<p>any suggestions?
thanks!</p>
