select value in spinner and pass id of that value to server in android
<p>I have got list of "client_id' and "organization" from JSON response and need to passe these organization list to spinner , but when user select organization name from spinner then need to pass client_id associated with that organization to server.</p>

<p>here is my code .</p>

<pre><code>   try {

      //*** Getting Array of Attributes
            attributes = jsonreturn.getJSONObject(TAG_ATTRIBUTE);
            String status = attributes.getString(TAG_VALIDCODE);
            JSONObject clients = jsonreturn.getJSONObject(TAG_CLIENTS);
            JSONArray client = clients.getJSONArray(TAG_CLIENT);

            final String[] list_client_id = new String[client.length()+1];
            list_client_id[0]= "Select Client";
            final String[] list_client_name = new String[client.length()];

       if(status.equals("200")){

     for(int i = 0; i &lt; client.length(); i++)

         {
            JSONObject clientlist = client.getJSONObject(i);

     //***** Storing each JSON item in variable
             String client_id = clientlist.getString(TAG_CLIENT_ID);
             String organization = clientlist.getString(TAG_ORGANIZATION);



          list_client_id[i+1]= clientlist.getString(TAG_CLIENT_ID);
          list_client_name[i]= clientlist.getString(TAG_ORGANIZATION);
         }
       }

       else{
            Toast.makeText(this, "Invalid Details", 1000).show();       }

        ClientNameSpinner = (Spinner)findViewById(R.id.ClientId);



        ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt; (this, android.R.layout.simple_spinner_item, list_client_name);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        ClientNameSpinner.setAdapter(adapter);

       /* ArrayAdapter&lt;String&gt; adapterid = new ArrayAdapter&lt;String&gt; (this, android.R.layout.simple_spinner_item, list_client_id);
        adapterid.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        ClientNameSpinner.setAdapter(adapterid);*/

}
            catch (JSONException e)
            {
            e.printStackTrace();
            } 
</code></pre>
