title: how to populate spinner with default prompt from Mysql using Json
body: <p>I'm using mysql with android studio.
  I want to set default prompt to the spinner. I'm also tried to set same value from XML with spinner attribute for prompt. But it's not work properly.Below is my code.</p>
  
  <pre><code>public static final String CollegeNamearray = "college";
  public static final String JSON_ARRAY = "result";
  public static final String JSON_ID = "id";
  private JSONArray result;
  Spinner spinner;
  spinner = (Spinner) findViewById(R.id.spinner);
  arrayList = new ArrayList&lt;String&gt;();
  
  
  getdata();
  shared=getSharedPreferences(AppPreference.USER_DETAILS, Context.MODE_PRIVATE);
  
  spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
  @Override
  public void onItemSelected(AdapterView&lt;?&gt; parent, View view, int position, long id) {
  item = getcollegeid(position).toString();
  
  }
  
  @Override
  public void onNothingSelected(AdapterView&lt;?&gt; adapterView) {
  txtview1.setText("");
  }
  
  });
  
  
  private void getdata() {
  
  final StringRequest stringRequest = new StringRequest(URLs.HttpUrlgetcollege,
  new Response.Listener&lt;String&gt;() {
  @Override
  public void onResponse(String response) {
  
  
  JSONObject j = null;
  
  try {
  j = new JSONObject(response);
  result = j.getJSONArray(JSON_ARRAY);
  collegelist(result);
  } catch (JSONException e) {
  e.printStackTrace();
  }
  
  //    Toast.makeText(getApplicationContext(),response,Toast.LENGTH_LONG).show();
  }
  },
  new Response.ErrorListener() {
  @Override
  public void onErrorResponse(VolleyError error) {
  }
  });
  RequestQueue requestQueue = Volley.newRequestQueue(this);
  requestQueue.add(stringRequest);
  }
  
  private void collegelist(JSONArray j) {
  for (int i = 0; i &lt; j.length(); i++) {
  try {
  JSONObject json = j.getJSONObject(i);
  arrayList.add(json.getString(CollegeNamearray));
  } catch (JSONException e) {
  e.printStackTrace();
  }
  }
  
  spinner.setAdapter(new ArrayAdapter&lt;String&gt;(login.this, android.R.layout.simple_spinner_dropdown_item, arrayList));
  
  }
  </code></pre>
  
  <p>please give solution to set prompt before data being loaded.</p>
  
  <p>Thanks in Advance.  </p>