title: Spinner Array List
body: <p>The spinner items come from JSON object. I already get the JSON object and put in the spinner. But I have this kind of issue at spinner in android that if I choose a cat from spinner choices and after I clicked, it will not show on the spinner item selected. See the picture for the sample. Is there anything wrong or I forgot to add some lines of code.</p>
  
  <p><a href="https://i.stack.imgur.com/cXHPR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cXHPR.png" alt="enter image description here"></a></p>
  
  <p>UPDATED: image and XML
  <a href="https://i.stack.imgur.com/4BokM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4BokM.png" alt="enter image description here"></a></p>
  
  <p>XML</p>
  
  <pre><code>&lt;android.support.constraint.ConstraintLayout 
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      xmlns:tool="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"&gt;
  &lt;LinearLayout
     android:layout_width="match_parent"
     android:layout_height="40dp"
     android:layout_marginTop="5dp"
     android:layout_gravity="center"
     android:orientation="vertical"&gt;
      &lt;Spinner
          android:id="@+id/spinnerdropdown"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_gravity="center"
          android:padding="3dp"
          android:spinnerMode="dropdown"
          android:textColor="#fff"
          android:layout_centerInParent="true"
          android:background="@drawable/bckg_spinner"/&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>JAVA</p>
  
  <pre><code>public class ProfileDept extends AppCompatActivity {
  
  ArrayList&lt;String&gt; ArrayListSpinner = new ArrayList&lt;String&gt;();
  Spinner spinner;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_profiledept);
      process.execute();
  
      Spinner spinner = findViewById(R.id.spinnerdropdown);
      ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_spinner_item, ArrayListSpinner);
      spinner.setAdapter(adapter);
      spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView&lt;?&gt; parent, View view, int position, long id) {
              Log.v("item", (String) parent.getItemAtPosition(position));
              ((TextView) parent.getChildAt(0)).setTextColor(Color.WHITE);
          }
  
          @Override
          public void onNothingSelected(AdapterView&lt;?&gt; parent) {
          }
      });
  }
      class fetchData extends AsyncTask&lt;Void, Void, String&gt; {
  
          @Override
          protected String doInBackground(Void... voids) {
  
              try {
                  URL url = new URL("https://Account/api/Profile?TestAccount");
                  HttpsURLConnection httpsURLConnection = (HttpsURLConnection) url.openConnection();
  
                  httpsURLConnection.setRequestProperty("Content-Type", "application/json");
                  httpsURLConnection.setRequestMethod("GET");   //POST or GET
                  httpsURLConnection.connect();
  
                  int statusCode = httpsURLConnection.getResponseCode();
                  statusMsg = httpsURLConnection.getResponseMessage();
  
                  if (statusCode == 200) {
                      InputStream it = new BufferedInputStream(httpsURLConnection.getInputStream());
                      InputStreamReader read = new InputStreamReader(it);
                      BufferedReader buff = new BufferedReader(read);
                      StringBuilder dta = new StringBuilder();
                      String chunks;
  
                      while ((chunks = buff.readLine()) != null) {
                          dta.append(chunks);
                          JSONArray jsonArray = new JSONArray(dta.toString());
  
                          for (int i = 0; i &lt; jsonArray.length(); i++) {
                              JSONObject jsonpass = (JSONObject) jsonArray.get(i);
                              ArrayListSpinner.add(jsonpass.getString("Username"));
                          }
  
                      }
                      return dta.toString();
  
                  } else {
  
                  }
              } catch (MalformedURLException e) {
                  e.printStackTrace();
              } catch (IOException e) {
                  e.printStackTrace();
              } catch (JSONException e) {
                  e.printStackTrace();
              }
              return null;
          }
  
          protected void onPostExecute (String aVoid) {
              super.onPostExecute(aVoid);
          }
  
      }
  }
  </code></pre>