title: Arraylist not working, items do not stack up
body: <p>So, I am trying to get some info from <code>database</code> and save it into an <code>ArrayList</code>, so later I can add dinamically <code>buttons</code> according to the <code>length</code> and <code>items</code> from that list. </p>
  
  <p>code: </p>
  
  <pre><code>private List&lt;String&gt; probleme = new ArrayList&lt;&gt;();
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_home);
  
      if (SharedPrefManager.getInstance(this).isLoggedIn()) {
          CautaProbleme();
          for(int i=0; i&lt;probleme.size(); i++) {
              Button myButton = new Button(this);
              myButton.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
              myButton.setText(probleme.get(i));
              LinearLayout layout = (LinearLayout) findViewById(R.id.linear_home);
              layout.addView(myButton);
          }
      }`
  </code></pre>
  
  <p>CautaProbleme method: </p>
  
  <pre><code>private void CautaProbleme(){
      class CautaProbleme extends AsyncTask&lt;Void, Void, String&gt; {
          User user = SharedPrefManager.getInstance(getApplicationContext()).getUser();
          final String departament = String.valueOf(user.getDepartament());
          @Override
          protected String doInBackground(Void... voids) {
              //creating request handler object
              RequestHandler requestHandler = new RequestHandler();
  
              //creating request parameters
              HashMap&lt;String, String&gt; params = new HashMap&lt;&gt;();
              params.put("departament", departament);
  
              //returing the response
              return requestHandler.sendPostRequest(URLs.URL_PROBLEME, params);
          }
  
          @Override
          protected void onPreExecute() {
              super.onPreExecute();
              //displaying the progress bar while user registers on the server
          }
  
          @Override
          protected void onPostExecute(String s) {
              super.onPostExecute(s);
              //hiding the progressbar after completion
  
              try {
                  //converting response to json object
                  JSONObject obj = new JSONObject(s);
  
                  //if no error in response
                  if (!obj.getBoolean("error")) {
                      JSONArray problemeArray = obj.getJSONArray("probleme");
                      for (int i = 0; i &lt; problemeArray.length(); i++) {
                          JSONObject problema = problemeArray.getJSONObject(i);
                          // Verificare daca s-au primit probleme trimise de server
                          if (!problema.isNull("Problema")) {
                              String situatie = problema.getString("Problema");
                              probleme.add(situatie);
                          }
                      }
  
                  } else {
                      Toast.makeText(getApplicationContext(), "Some error occurred", Toast.LENGTH_SHORT).show();
                  }
              } catch (JSONException e) {
                  e.printStackTrace();
              }
          }
      }
      CautaProbleme ru =new CautaProbleme();
      ru.execute();
  }
  </code></pre>
  
  <p>The <code>JSON</code> response it's alright, the <code>problemeArray</code> looks good, but the problem it's that the <code>.add()</code> command does not add the <code>strings</code> to the list, so the <code>for</code> for creating <code>buttons</code> does not do anything, having an empty <code>list</code>. I have declared <code>private List probleme = new ArrayList&lt;&gt;();</code> globally.</p>