title: Spinner inside a PopUp Window
body: <p>I've created a popup window and put a spinner inside it. But I can't get values when an item is selected from it.</p>
  
  <p>My code to create popup:</p>
  
  <pre><code>LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      popwindow=new PopupWindow(inflater.inflate(R.layout.addpain, null,false),300,350,true);
      popwindow.showAtLocation(this.findViewById(R.id.tabHost), Gravity.CENTER, 0, 0);
  </code></pre>
  
  <p>XML file of PopUp</p>
  
  <pre><code>&lt;LinearLayout  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:background="#A0BBBBBB"&gt;
  
  
  
  &lt;RelativeLayout
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:background="#A0BBBBBB" &gt;
  
      &lt;TextView
          android:id="@+id/addpaintext"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:text="@string/addpain"
          android:textColor="#000000"
          android:textSize="18dp"
          android:typeface="serif" /&gt;
  
      &lt;EditText
          android:id="@+id/statustbox"
          android:layout_width="fill_parent"
          android:layout_height="150dp"
          android:layout_alignParentLeft="true"
          android:layout_below="@+id/addpaintext"
          android:layout_marginTop="17dp"
          android:hint="@string/addpain"
          android:inputType="textMultiLine"
          android:textColor="#000000"
          android:textSize="20dp"
          android:typeface="serif" /&gt;
  
      &lt;Button
          android:id="@+id/addpainbutton"
          android:layout_width="80dp"
          android:layout_height="45dp"
          android:layout_alignParentLeft="true"
          android:layout_below="@+id/statustbox"
          android:layout_marginLeft="18dp"
          android:layout_marginTop="98dp"
          android:onClick="statusupload"
          android:text="@string/statusupload" /&gt;
  
      &lt;Button
          android:id="@+id/cancelbutton"
          android:layout_width="80dp"
          android:layout_height="45dp"
          android:layout_alignBaseline="@+id/addpainbutton"
          android:layout_alignBottom="@+id/addpainbutton"
          android:layout_alignParentRight="true"
          android:layout_marginRight="18dp"
          android:onClick="canceladdpain"
          android:text="@string/cancel" /&gt;
  
  
  
      &lt;Spinner
          android:id="@+id/spinner_list"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignLeft="@+id/addpainbutton"
          android:layout_alignRight="@+id/cancelbutton"
          android:layout_below="@+id/statustbox"
          android:layout_marginTop="20dp"
          android:prompt="@string/testtxt"
          android:entries="@array/list"/&gt;
  
  &lt;/RelativeLayout&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>My StatusUpload Function:</p>
  
  <pre><code>public void statusupload(View view)
  {
  
      EditText status=(EditText) popwindow.getContentView().findViewById(R.id.statustbox); 
  
      Spinner spinner=(Spinner) popwindow.getContentView().findViewById(R.id.spinner_list);    
  
      spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
  
          @Override
          public void onItemSelected(AdapterView&lt;?&gt; parent, View view, int position,long id)
          {
              category=parent.getSelectedItem().toString();
          }
  
  
          @Override
          public void onNothingSelected(AdapterView&lt;?&gt; parent) {
              category="Miscellaneous";
          }
      });
  
      Toast.makeText(getBaseContext(),category, Toast.LENGTH_LONG).show();
  
  
  }
  </code></pre>
  
  <p>What happens is the vraible category isnt getting any values !! IT's just blank.</p>