Android Dialog alert
<p>I want to create custom dialog for entering text and  date. For that i have created a layout xml file which is </p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent" android:orientation="vertical"&gt;
    &lt;EditText android:id="@+id/dialogEditText" android:text="Enter Your Text Here" android:layout_height="wrap_content" android:layout_width="match_parent"&gt;&lt;/EditText&gt;
    &lt;DatePicker android:id="@+id/datPicker" android:layout_height="wrap_content" android:layout_width="match_parent" &gt;&lt;/DatePicker&gt;
    &lt;LinearLayout android:id="@+id/linearLayout1" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"&gt;
     &lt;Button android:text="Add" android:id="@+id/dialogAddBtn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true"&gt;&lt;/Button&gt;
     &lt;Button android:text="Cancel" android:id="@+id/dialogCancelBtn" android:layout_width="200px" android:layout_height="wrap_content" android:layout_centerHorizontal="true"&gt;&lt;/Button&gt;
    &lt;/LinearLayout&gt;
&lt;/LinearLayout&gt;
</code></pre>

<p>and my class code is :</p>

<pre><code>  final Dialog d= new Dialog(obj);
                 Window window= d.getWindow();
                 window.setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND, WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
                 window.setTitle("Add Item");
                 window.setContentView(R.layout.dialog_view);

                 final EditText input= (EditText) obj.findViewById(R.id.dialogEditText);
                 Button okBtn= (Button) obj.findViewById(R.id.dialogAddBtn);
                 okBtn.setOnClickListener(new OnClickListener() {

                        public void onClick(View v) {
                            toDoItems.add(0,input.getText().toString());
                              aa.notifyDataSetChanged();
                              //d.dismiss();
                        }
                    });
                    d.show();
</code></pre>

<p>This is showing dialog perfectly but when i click on ok than it is generating exception which is :</p>

<pre><code>04-06 14:01:24.415: ERROR/AndroidRuntime(1189): FATAL EXCEPTION: main
04-06 14:01:24.415: ERROR/AndroidRuntime(1189): java.lang.NullPointerException
04-06 14:01:24.415: ERROR/AndroidRuntime(1189):     at com.example.wrox.MyDialog.showInputDialog(MyDialog.java:66)
04-06 14:01:24.415: ERROR/AndroidRuntime(1189):     at com.example.wrox.ToDoItems$1.onClick(ToDoItems.java:69)
04-06 14:01:24.415: ERROR/AndroidRuntime(1189):     at android.view.View.performClick(View.java:2485)
04-06 14:01:24.415: ERROR/AndroidRuntime(1189):     at android.view.View$PerformClick.run(View.java:9080)
04-06 14:01:24.415: ERROR/AndroidRuntime(1189):     at android.os.Handler.handleCallback(Handler.java:587)
04-06 14:01:24.415: ERROR/AndroidRuntime(1189):     at android.os.Handler.dispatchMessage(Handler.java:92)
04-06 14:01:24.415: ERROR/AndroidRuntime(1189):     at android.os.Looper.loop(Looper.java:123)
04-06 14:01:24.415: ERROR/AndroidRuntime(1189):     at android.app.ActivityThread.main(ActivityThread.java:3683)
04-06 14:01:24.415: ERROR/AndroidRuntime(1189):     at java.lang.reflect.Method.invokeNative(Native Method)
04-06 14:01:24.415: ERROR/AndroidRuntime(1189):     at java.lang.reflect.Method.invoke(Method.java:507)
04-06 14:01:24.415: ERROR/AndroidRuntime(1189):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-06 14:01:24.415: ERROR/AndroidRuntime(1189):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-06 14:01:24.415: ERROR/AndroidRuntime(1189):     at dalvik.system.NativeStart.main(Native Method)
</code></pre>

<p>Please suggest me some solutions.......</p>
