title: Android: Get Textview value of Spinner on Button click
body: <p>I have a <code>Spinner</code> and i am populating it with custom <code>SimpleCursorAdapter</code>. Spinner item layout contains two <code>TextView</code>s, One TextView for item id and it is not visible other is for item name. I want to get this item id on button click event then insert it to Sqlite database. I get the id on <code>setOnItemSelectedListener</code> of <code>Spinner</code> as</p>
  
  <pre><code>companySpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
              @Override
              public void onItemSelected(AdapterView&lt;?&gt; parent, View view, int position, long id) {
  
                  // Get selected row data to show on screen
                  String companyId = ((TextView) view.findViewById(R.id.spinnerItemIdTv)).getText().toString();
                  Toast.makeText(getActivity(), companyId, Toast.LENGTH_LONG).show();
                  Log.w(TAG, "companyId:" + companyId);
  
              }
  
              @Override
              public void onNothingSelected(AdapterView&lt;?&gt; parent) {
  
  
              }
          });
  </code></pre>
  
  <p>and Spinner Item Layout</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:orientation="horizontal" &gt;
  
      &lt;TextView
          android:id="@+id/spinnerItemIdTv"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:textColor="#888"
          android:textSize="20sp"
          android:visibility="gone"/&gt;
  
      &lt;TextView
          android:id="@+id/spinnerItemNameTv"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:textColor="#888"
          android:textSize="20sp" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>But couldnt make it on button click. Any help would be appreciated.</p>