title: OnSelect of Spinner show a Dialog with listview Android
body: <p>I have a Spinner in which i am showing a list .Now i want to show that list in a custom dialog that has listview on selection of list view item .Spinner value will be the value that is selected from the listview item .</p>
  
  <p>This is my Spinner </p>
  
  <pre><code>&lt;Spinner
      android:id="@+id/Tittle"
      android:layout_width="290dp"
      android:layout_marginLeft="5dp"
      android:layout_marginTop="5dp"
      android:visibility="gone"
      android:layout_height="wrap_content"/&gt;
  </code></pre>
  
  <p>This is how i am setting the value in the spinner </p>
  
  <pre><code>public void setTittle() {
          String[] tittlearray = { "Mr.", "Mrs.", "Ms" };
          ArrayAdapter&lt;String&gt; dataAdapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_spinner_item, tittlearray);
          dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_item);
          tittleSpinner.setAdapter(dataAdapter);
      }
  </code></pre>
  
  <p>This is my ListView </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical" &gt;
  
      &lt;ListView
          android:id="@+id/listview"
          android:layout_height="wrap_content"
          android:layout_width="match_parent"&gt;
      &lt;/ListView&gt;
  
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Now i want this list in the Custom Dialog.Please help me to get this .  </p>
  
  <p><strong>EDIT After USING Gaurav Code</strong></p>
  
  <pre><code>Exception i am getting 
  09-12 13:46:04.436: E/InputEventReceiver(7206): Exception dispatching input event.
  09-12 13:46:04.437: E/MessageQueue-JNI(7206): Exception in MessageQueue callback: handleReceiveCallback
  09-12 13:46:04.469: E/MessageQueue-JNI(7206): java.lang.NullPointerException
  09-12 13:46:04.469: E/MessageQueue-JNI(7206):   at com.example.bookingpage.MainActivity$5.onTouch(MainActivity.java:215)
  09-12 13:46:04.469: E/MessageQueue-JNI(7206):   at android.view.View.dispatchTouchEvent(View.java:7138)
  09-12 13:46:04.469: E/MessageQueue-JNI(7206):   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2238)
  09-12 13:46:04.469: E/MessageQueue-JNI(7206):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1935)
  09-12 13:46:04.469: E/MessageQueue-JNI(7206):   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2244)
  09-12 13:46:04.469: E/MessageQueue-JNI(7206):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1907)
  09-12 13:46:04.469: E/MessageQueue-JNI(7206):   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2244)
  09-12 13:46:04.469: E/MessageQueue-JNI(7206):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1907)
  09-12 13:46:04.469: E/MessageQueue-JNI(7206):   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2244)
  09-12 13:46:04.469: E/MessageQueue-JNI(7206):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1907)
  09-12 13:46:04.469: E/MessageQueue-JNI(7206):   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2244)
  09-12 13:46:04.469: E/MessageQueue-JNI(7206):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1907)
  09-12 13:46:04.469: E/MessageQueue-JNI(7206):   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2244)
  09-12 13:46:04.469: E/MessageQueue-JNI(7206):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1907)
  09-12 13:46:04.469: E/MessageQueue-JNI(7206):   at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1938)
  09-12 13:46:04.469: E/MessageQueue-JNI(7206):   at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1392)
  09-12 13:46:04.469: E/MessageQueue-JNI(7206):   at android.app.Activity.dispatchTouchEvent(Activity.java:2408)
  09-12 13:46:04.469: E/MessageQueue-JNI(7206):   at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1886)
  09-12 13:46:04.469: E/MessageQueue-JNI(7206):   at android.view.View.dispatchPointerEvent(View.java:7323)
  09-12 13:46:04.469: E/MessageQueue-JNI(7206):   at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3520)
  09-12 13:46:04.469: E/MessageQueue-JNI(7206):   at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:3454)
  09-12 13:46:04.469: E/MessageQueue-JNI(7206):   at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:4543)
  09-12 13:46:04.469: E/MessageQueue-JNI(7206):   at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:4522)
  09-12 13:46:04.469: E/MessageQueue-JNI(7206):   at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:4618)
  09-12 13:46:04.469: E/MessageQueue-JNI(7206):   at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:171)
  09-12 13:46:04.469: E/MessageQueue-JNI(7206):   at android.os.MessageQueue.nativePollOnce(Native Method)
  09-12 13:46:04.469: E/MessageQueue-JNI(7206):   at android.os.MessageQueue.next(MessageQueue.java:125)
  09-12 13:46:04.469: E/MessageQueue-JNI(7206):   at android.os.Looper.loop(Looper.java:140)
  09-12 13:46:04.469: E/MessageQueue-JNI(7206):   at android.app.ActivityThread.main(ActivityThread.java:4987)
  09-12 13:46:04.469: E/MessageQueue-JNI(7206):   at java.lang.reflect.Method.invokeNative(Native Method)
  09-12 13:46:04.469: E/MessageQueue-JNI(7206):   at java.lang.reflect.Method.invoke(Method.java:511)
  09-12 13:46:04.469: E/MessageQueue-JNI(7206):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
  09-12 13:46:04.469: E/MessageQueue-JNI(7206):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
  09-12 13:46:04.469: E/MessageQueue-JNI(7206):   at dalvik.system.NativeStart.main(Native Method)
  09-12 13:46:04.470: D/AndroidRuntime(7206): Shutting down VM
  09-12 13:46:04.470: W/dalvikvm(7206): threadid=1: thread exiting with uncaught exception (group=0x40de8908)
  09-12 13:46:04.493: E/AndroidRuntime(7206): FATAL EXCEPTION: main
  09-12 13:46:04.493: E/AndroidRuntime(7206): java.lang.NullPointerException
  09-12 13:46:04.493: E/AndroidRuntime(7206):     at com.example.bookingpage.MainActivity$5.onTouch(MainActivity.java:215)
  09-12 13:46:04.493: E/AndroidRuntime(7206):     at android.view.View.dispatchTouchEvent(View.java:7138)
  09-12 13:46:04.493: E/AndroidRuntime(7206):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2238)
  09-12 13:46:04.493: E/AndroidRuntime(7206):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1935)
  09-12 13:46:04.493: E/AndroidRuntime(7206):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2244)
  09-12 13:46:04.493: E/AndroidRuntime(7206):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1907)
  09-12 13:46:04.493: E/AndroidRuntime(7206):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2244)
  09-12 13:46:04.493: E/AndroidRuntime(7206):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1907)
  09-12 13:46:04.493: E/AndroidRuntime(7206):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2244)
  09-12 13:46:04.493: E/AndroidRuntime(7206):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1907)
  09-12 13:46:04.493: E/AndroidRuntime(7206):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2244)
  09-12 13:46:04.493: E/AndroidRuntime(7206):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1907)
  09-12 13:46:04.493: E/AndroidRuntime(7206):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2244)
  09-12 13:46:04.493: E/AndroidRuntime(7206):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1907)
  09-12 13:46:04.493: E/AndroidRuntime(7206):     at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1938)
  09-12 13:46:04.493: E/AndroidRuntime(7206):     at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1392)
  09-12 13:46:04.493: E/AndroidRuntime(7206):     at android.app.Activity.dispatchTouchEvent(Activity.java:2408)
  09-12 13:46:04.493: E/AndroidRuntime(7206):     at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1886)
  09-12 13:46:04.493: E/AndroidRuntime(7206):     at android.view.View.dispatchPointerEvent(View.java:7323)
  09-12 13:46:04.493: E/AndroidRuntime(7206):     at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3520)
  09-12 13:46:04.493: E/AndroidRuntime(7206):     at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:3454)
  09-12 13:46:04.493: E/AndroidRuntime(7206):     at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:4543)
  09-12 13:46:04.493: E/AndroidRuntime(7206):     at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:4522)
  09-12 13:46:04.493: E/AndroidRuntime(7206):     at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:4618)
  09-12 13:46:04.493: E/AndroidRuntime(7206):     at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:171)
  09-12 13:46:04.493: E/AndroidRuntime(7206):     at android.os.MessageQueue.nativePollOnce(Native Method)
  09-12 13:46:04.493: E/AndroidRuntime(7206):     at android.os.MessageQueue.next(MessageQueue.java:125)
  09-12 13:46:04.493: E/AndroidRuntime(7206):     at android.os.Looper.loop(Looper.java:140)
  09-12 13:46:04.493: E/AndroidRuntime(7206):     at android.app.ActivityThread.main(ActivityThread.java:4987)
  09-12 13:46:04.493: E/AndroidRuntime(7206):     at java.lang.reflect.Method.invokeNative(Native Method)
  09-12 13:46:04.493: E/AndroidRuntime(7206):     at java.lang.reflect.Method.invoke(Method.java:511)
  09-12 13:46:04.493: E/AndroidRuntime(7206):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
  09-12 13:46:04.493: E/AndroidRuntime(7206):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
  09-12 13:46:04.493: E/AndroidRuntime(7206):     at dalvik.system.NativeStart.main(Native Method)
  </code></pre>