title: how to get selectd code and selected name value from spinner in android
body: <p>this is my Asynk task am getting data from server and calling in Oncreate method</p>
  
  <pre><code>   class download extends AsyncTask&lt;Void, Void, Void&gt; {
              String result;
  
              @Override
              protected void onPreExecute() {
                  // TODO Auto-generated method stub
                  super.onPreExecute();
  
                  pDialog = new ProgressDialog(RDistributor.this);
                  pDialog.setTitle("CheckUser Connection");
                  pDialog.setMessage("Please wait...");
                  pDialog.show();
              }
  
              @Override
              protected Void doInBackground(Void... params) {
                  // TODO Auto-generated method stub
  
                  try {
                      result = JSONfunctions2.getJSONfromURL(URL + "?spokecode="
                              + "GUJAHM270");
                      _jarray1 = new JSONArray(result);
  
                      stringArray = new ArrayList&lt;String&gt;();
                      // stringArray.add("Select Role");
                      for (int i = 0; i &lt;= _jarray1.length(); i++) {
  
                          JSONObject _obj = _jarray1.getJSONObject(i);
                          SpokeCode = _obj.getString("SpokeCode").toString();
                          DistributerCode = _obj.getString("DistributerCode")
                                  .toString();
                          DistributerName = _obj.getString("DistributerName")
                                  .toString();
  
                          stringArray.add(DistributerName);
  
                      }
  
                  } catch (JSONException e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                  }
  
                  return null;
              }
  
              @Override
              protected void onPostExecute(Void result) {
                  // TODO Auto-generated method stub
  
                  if (_jarray1.length() == 0) {
                      showpopup("All Distributers had already been registered!");
  
                  } else {
                      dataAdapter = new ArrayAdapter&lt;String&gt;(RDistributor.this,
                              R.layout.spinner_item, stringArray);
                      // ArrayAdapter&lt;String&gt; dataAdapter = new
                      // ArrayAdapter&lt;String&gt;(this,R.layout.spinner_item,
                      // stringArray);
                      dataAdapter
                              .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                      // set the ArrayAdapter to the spinner
                      rolespinner.setAdapter(dataAdapter);
                  }
                  pDialog.dismiss();
                  super.onPostExecute(result);
  
              }
          }
  </code></pre>
  
  <p>this is itemselected of spinner and getting value .</p>
  
  <pre><code>rolespinner.setOnItemSelectedListener(new OnItemSelectedListener() {
  
              @Override
              public void onItemSelected(AdapterView&lt;?&gt; arg0, View arg1,
                      int arg2, long arg3) {
                  // TODO Auto-generated method stub
  
                  DistributerName=rolespinner.getSelectedItem().toString();
                  Toast.makeText(RDistributor.this, DistributerName, 10000).show();
  
  
              }
  
              @Override
              public void onNothingSelected(AdapterView&lt;?&gt; arg0) {
                  // TODO Auto-generated method stub
  
              }
          });
  
      }
  </code></pre>
  
  <p>i am printing data distributerName in Spinner which is coming from server also distributerCode and spoke code coming from server i want when i select distributor name corresponding i get value of distributor code and spoke code selection of ditributorname from drop down please suggest me how i will achieve this .i am facing issue to get this .</p>