Spinner in Custom Dialog giving force close
<p>The Alert Dialog being shown nicely, when i click the spinner( spinner is in the Alert Dialog) it gives force close, kindly help    </p>

<pre><code>private void showDialogue(Activity a) {
        try {
                        // Inflating a layout for Alert Dialog
            LayoutInflater layoutInflater = (LayoutInflater) getApplicationContext()
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View view = layoutInflater.inflate(R.layout.prop_dialogue,null);
            view.findViewById(R.id.dialogue_btn_cancel).setOnClickListener(
                    Properties.this);
// Getting reference of Spinner      
   Spinner spin = (Spinner) view.findViewById(R.id.dialogue_spinner_count);
            setImage((ImageView) view.findViewById(R.id.dialogue_prop_icon),
                    getImageBitmap(position));
            setName((TextView) view.findViewById(R.id.dialogue_prop_name));
// Adapter for Spinner
ArrayAdapter&lt;CharSequence&gt; adapter = ArrayAdapter.createFromResource(
                Properties.this, R.array.prop_count,
                android.R.layout.simple_spinner_item);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            spin.setAdapter(adapter );
             spin.setOnItemSelectedListener(Properties.this);
            Builder b = new AlertDialog.Builder(this).setTitle("Properties")
                    .setNeutralButton("Submit",
                            new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog,
                                        int which) {

                                }
                            });
            b.setView(view);
            b.show();
        } catch (Exception e) {
            // TODO: handle exception
        }
    }
</code></pre>

<p>Error Shown in the Log</p>

<pre><code>06-06 12:09:22.971: E/AndroidRuntime(992): FATAL EXCEPTION: main
06-06 12:09:22.971: E/AndroidRuntime(992): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
06-06 12:09:22.971: E/AndroidRuntime(992):  at android.view.ViewRoot.setView(ViewRoot.java:509)
06-06 12:09:22.971: E/AndroidRuntime(992):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
06-06 12:09:22.971: E/AndroidRuntime(992):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
06-06 12:09:22.971: E/AndroidRuntime(992):  at android.app.Dialog.show(Dialog.java:241)
06-06 12:09:22.971: E/AndroidRuntime(992):  at android.app.AlertDialog$Builder.show(AlertDialog.java:802)
06-06 12:09:22.971: E/AndroidRuntime(992):  at android.widget.Spinner.performClick(Spinner.java:257)
06-06 12:09:22.971: E/AndroidRuntime(992):  at android.view.View$PerformClick.run(View.java:8816)
06-06 12:09:22.971: E/AndroidRuntime(992):  at android.os.Handler.handleCallback(Handler.java:587)
06-06 12:09:22.971: E/AndroidRuntime(992):  at android.os.Handler.dispatchMessage(Handler.java:92)
06-06 12:09:22.971: E/AndroidRuntime(992):  at android.os.Looper.loop(Looper.java:123)
06-06 12:09:22.971: E/AndroidRuntime(992):  at android.app.ActivityThread.main(ActivityThread.java:4627)
06-06 12:09:22.971: E/AndroidRuntime(992):  at java.lang.reflect.Method.invokeNative(Native Method)
06-06 12:09:22.971: E/AndroidRuntime(992):  at java.lang.reflect.Method.invoke(Method.java:521)
06-06 12:09:22.971: E/AndroidRuntime(992):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
06-06 12:09:22.971: E/AndroidRuntime(992):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
06-06 12:09:22.971: E/AndroidRuntime(992):  at dalvik.system.NativeStart.main(Native Method)
</code></pre>
