Spinner selected option must be stored in google form
<p><strong>main activity</strong></p>

<pre><code>package com.example.wastewarriorsnew;

public class MainActivity extends Activity implements OnItemSelectedListener {

final String myTag = "DocsUpload";
String location,name,check_in,check_out,recy,nonrecy,recy_wt,nonrec_wt,new_loc,num,total_wt;
InputStream is=null;
String result=null;
String line=null;
int code;
String id;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    // Spinner element
    Spinner spinner = (Spinner) findViewById(R.id.spinner1);

      // Spinner click listener
      spinner.setOnItemClickListener((OnItemClickListener) this);

      // Spinner Drop down elements
      List&lt;String&gt; categories = new ArrayList&lt;String&gt;();
      categories.add("Dehradun");
      categories.add("Pune");
      categories.add("Mumbai");
      categories.add("Delhi");
      categories.add("Goa");
      categories.add("Solapur");

      // Creating adapter for spinner
      ArrayAdapter&lt;String&gt; dataAdapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_spinner_item, categories);

      // Drop down layout style - list view with radio button
      dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

      // attaching data adapter to spinner
      spinner.setAdapter(dataAdapter);

    final EditText ed2 = (EditText)findViewById(R.id.workername);
    final EditText ed3 = (EditText)findViewById(R.id.Checkin);
    final EditText ed4 = (EditText)findViewById(R.id.Chechout);
    final EditText ed5 = (EditText)findViewById(R.id.Recycle);
    final EditText ed6 = (EditText)findViewById(R.id.NonRecycle);
    final EditText ed7 = (EditText)findViewById(R.id.Recycleweight);
    final EditText ed8 = (EditText)findViewById(R.id.Nonweight);
    final EditText ed9 = (EditText)findViewById(R.id.newlocation);
    final EditText ed10 = (EditText)findViewById(R.id.Number);
    final EditText ed11 = (EditText)findViewById(R.id.totalweight);


    final Button bt1=(Button)findViewById(R.id.button1);
bt1.setOnClickListener(new View.OnClickListener() {

    @Override
    public void onClick(View arg0) {


        name=ed2.getText().toString();
        check_in=ed3.getText().toString();
        check_out=ed4.getText().toString();
        recy=ed5.getText().toString();
        nonrecy=ed6.getText().toString();
        recy_wt=ed7.getText().toString();
        nonrec_wt=ed8.getText().toString();
        new_loc=ed9.getText().toString();
        num=ed10.getText().toString();
        total_wt=ed11.getText().toString();

        Log.i(myTag, "OnCreate()");
        Thread t = new Thread(new Runnable() {
            @Override
            public void run() {
                postData();

            }
        });
        t.start();
        // TODO Auto-generated method stub

    }

});

}
public void postData() {

    String fullUrl = "https://docs.google.com/forms/d/e/1FAIpQLScXtmI3Ev-cxc04Ai5_6zmnudLoF6W9g/formResponse";
    HttpRequest mReq = new HttpRequest();


    final EditText ed2 = (EditText)findViewById(R.id.workername);
    final EditText ed3 = (EditText)findViewById(R.id.Checkin);
    final EditText ed4 = (EditText)findViewById(R.id.Chechout);
    final EditText ed5 = (EditText)findViewById(R.id.Recycle);
    final EditText ed6 = (EditText)findViewById(R.id.NonRecycle);
    final EditText ed7 = (EditText)findViewById(R.id.Recycleweight);
    final EditText ed8 = (EditText)findViewById(R.id.Nonweight);
    final EditText ed9 = (EditText)findViewById(R.id.newlocation);
    final EditText ed10 = (EditText)findViewById(R.id.Number);
    final EditText ed11 = (EditText)findViewById(R.id.totalweight);

    //String col1 = "Hello";
    //String col2 = "World";

    String data =// "entry.1178044604=" + URLEncoder.encode(location) + "&amp;" + 
                  "entry.224535232=" + URLEncoder.encode(name)      + "&amp;" +
                   "entry.829233547="+ URLEncoder.encode(check_in)  + "&amp;" +
                    "entry.1814499237=" + URLEncoder.encode(check_out)+"&amp;"+
                    "entry.1206946186="+ URLEncoder.encode(recy)+ "&amp;" +
                  "entry.651664232=" + URLEncoder.encode(nonrecy) + "&amp;" +
                    "entry.1115147786="+ URLEncoder.encode(recy_wt)+"&amp;"+
                    "entry.472878985=" + URLEncoder.encode(nonrec_wt) +"&amp;"+
                    "entry.1615743649="+ URLEncoder.encode(new_loc)+"&amp;"+
                    "entry.2005603514="+ URLEncoder.encode(num)+"&amp;"+
                    "entry.871683438="+ URLEncoder.encode(total_wt);

    String response = mReq.sendPost(fullUrl, data);
    Log.i(myTag, response);

}
@Override
public void onItemSelected(AdapterView&lt;?&gt; parent, View view, int position, long id) {
    // TODO Auto-generated method stub
     // On selecting a spinner item
      String item = parent.getItemAtPosition(position).toString();

      // Showing selected spinner item
      Toast.makeText(parent.getContext(), "Selected: " + item, Toast.LENGTH_LONG).show();
}
@Override
public void onNothingSelected(AdapterView&lt;?&gt; arg0) {
    // TODO Auto-generated method stub

} 

}
</code></pre>

<p><strong>xml file</strong></p>

<pre><code>&lt;ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 android:id="@+id/scrollView1"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:background="@drawable/back" &gt;

&lt;LinearLayout
android:layout_width="match_parent"
android:layout_height="630dp"

android:orientation="vertical"
tools:context=".MainActivity" &gt;

    &lt;TextView android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:text="Location address"    /&gt;

    &lt;Spinner
        android:id="@+id/spinner1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" /&gt;

    &lt;TextView android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:text="Worker name"/&gt;
    &lt;EditText
    android:id="@+id/workername"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="Worker Name"
    android:inputType="text" /&gt;

    &lt;TextView android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:text="Check in"/&gt;

&lt;EditText
    android:id="@+id/Checkin"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="Check-in time"
    android:inputType="time" /&gt;

&lt;TextView android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:text="Check out"
      /&gt;

 &lt;EditText
 android:id="@+id/Chechout"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:hint="Check-out time"
 android:inputType="time" /&gt;

 &lt;TextView android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:text="No. of recyclable bags"
      /&gt;
 &lt;EditText
   android:id="@+id/Recycle"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:hint="No of bags used for recyclable material"
   android:inputType="number" /&gt;

 &lt;TextView android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:text="No. of non-recyclable bags"
      /&gt;
 &lt;EditText
android:id="@+id/NonRecycle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="No of bags used for non-recyclable material"
android:inputType="number" /&gt;

 &lt;TextView android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:text="Wt. of recycle material"
      /&gt;
 &lt;EditText
android:id="@+id/Recycleweight"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Weight of recyclable material"
android:inputType="text" /&gt;

 &lt;TextView android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:text="Wt. of non-recycle material"
      /&gt;
 &lt;EditText
    android:id="@+id/Nonweight"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="Weight of non-recyclable material"
    android:inputType="text" /&gt;

 &lt;TextView android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:text="New location(if shifted)"
      /&gt;
 &lt;EditText
    android:id="@+id/newlocation"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="New location(if shifted)"
    android:inputType="text" /&gt;

 &lt;TextView android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:text="No. of persons"
      /&gt;
 &lt;EditText
    android:id="@+id/Number"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="No. of persons per loaction"
    android:inputType="number" /&gt;

 &lt;TextView android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:text="Total weight"
      /&gt;
 &lt;EditText
     android:id="@+id/totalweight"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:hint="Total weight of recyclable and non-recyclable material"
     android:inputType="number" /&gt;

 &lt;LinearLayout 
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" &gt;

 &lt;Button
    android:id="@+id/button1"
    android:layout_width="80dp"
    android:layout_height="40dp"
    android:layout_marginLeft="40dp"
      android:layout_marginTop="50dp"
    android:text="Save" /&gt;

&lt;/LinearLayout&gt;
&lt;/LinearLayout&gt;
&lt;/ScrollView&gt;
</code></pre>

<p>The error i was getting in logcat is:</p>

<blockquote>
  <p>08-03 04:49:03.828: E/AndroidRuntime(773): java.lang.RuntimeException:
  Unable to start activity
  ComponentInfo{com.example./com.exampleMainActivity}:
  java.lang.ClassCastException: com.example.MainActivity cannot be cast
  to android.widget.AdapterView$OnItemClickListener</p>
</blockquote>

<p>but now there are no msgs in the logcat,but still the msg is:</p>

<blockquote>
  <p>Unfortunately stopped working.</p>
</blockquote>

<p>As the app will run,from main activity the details will be added and clicking on save button,it will be stored in google forms.
Help me .</p>