title: Lisview inside a Listview not working
body: <p>I am making an android app that shows weather using OWM 5day 3hour forecast API, The ui consists of EditText to input a city name, a button to initiate the call process, a listview that will display 5 entries (five days) and each day entry includes another listview that displays decription and temperature for every 3 hours in a day,
  I am able to see the listview for days but cannot see the nested listview for the hourly data. My classes include : MainActivity, WeatherAdapter to show 3hourly weather, DayAdapter to show day entries, and JsonToWeather data class that extracts data out of the Json response and make an Arraylist of data for only one particular day. I tried to log the error and highlighted the error position by a comment.
  MainActivity :</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  private static final String TAG = "MainActivity";
  private String responseJSON = null;
  ListView listView;
  ArrayList&lt;WeatherData&gt; weatherDataArrayList;
  WeatherAdapter weatherAdapter = null;
  EditText cityName;
  String city = null;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      listView = (ListView) findViewById(R.id.dayList);
      cityName = (EditText) findViewById(R.id.cityName);
      Button load = (Button) findViewById(R.id.loadButton);
      load.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              city = cityName.getText().toString();
              Log.d(TAG, "onClick: city is : " + city);
              if(city == null){
                  Toast toast = null;
                  toast.makeText(MainActivity.this,"Please Enter a city before continuing",Toast.LENGTH_LONG);
                  toast.show();
              } else {
  
                  String url = "http://api.openweathermap.org/data/2.5/forecast?q=" + (city.toLowerCase()) + "&amp;units=metric&amp;appid=8b10912e19fde267f36f6cb785ee7efd";
  
                  Log.d(TAG, "onCreate: staring download task");
                  DownloadJSON downloadJSON = new DownloadJSON();
                  downloadJSON.execute(url);
                  Log.d(TAG, "onCreate: after downloadtask");
              }
          }
      });
  
  
      if(weatherDataArrayList == null){
          Log.d(TAG, "onCreate: ArrayList is Still null");
      }
  }
  
  private class DownloadJSON extends AsyncTask&lt;String, Void, String&gt;{
      private static final String TAG = "DownloadJSON";
  
      private String downloadJSON(String url){
          StringBuilder jsonResult = new StringBuilder();
          try{
              URL apiURL = new URL(url);
              HttpURLConnection connection = (HttpURLConnection) apiURL.openConnection();
              int responseCode = connection.getResponseCode();
              Log.d(TAG, "downloadJSON: Response code "+ responseCode);
              BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
  
              int charReader;
              char[] inputBuffer = new char[500];
              while(true){
                  charReader = reader.read(inputBuffer);
                  if(charReader &lt; 0){
                      break;
                  }
                  if(charReader &gt; 0){
                      jsonResult.append(String.copyValueOf(inputBuffer, 0, charReader));
                  }
              }
              reader.close();
              return jsonResult.toString();
          }catch (MalformedURLException e){
              Log.e(TAG, "downloadJSON: URL is Invalid");
          }catch (IOException e){
              Log.e(TAG, "downloadJSON: IO Error");
          }
          return null;
      }
  
      @Override
      protected String doInBackground(String... strings) {
          Log.d(TAG, "doInBackground: url is : " + strings[0]);
          String jsonResponse = downloadJSON(strings[0]);
          if(jsonResponse == null){
              Log.e(TAG, "doInBackground: Error downloading");
          }
          return jsonResponse;
      }
  
      @Override
      protected void onPostExecute(String jsonResponse) {
          super.onPostExecute(jsonResponse);
          Log.d(TAG, "onPostExecute: json received is : " + jsonResponse);
          if(jsonResponse != null){
              JsonToWeatherData jtwd = new JsonToWeatherData();
              weatherDataArrayList = jtwd.extractor(jsonResponse);
              SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
              Calendar calendar = Calendar.getInstance();
              String date1 = simpleDateFormat.format(calendar.getTime());
              calendar.add(Calendar.DATE,1);
              String date2 = simpleDateFormat.format(calendar.getTime());
              calendar.add(Calendar.DATE,1);
              String date3 = simpleDateFormat.format(calendar.getTime());
              calendar.add(Calendar.DATE,1);
              String date4 = simpleDateFormat.format(calendar.getTime());
              calendar.add(Calendar.DATE,1);
              String date5 = simpleDateFormat.format(calendar.getTime());
              ArrayList&lt;String&gt; days = new ArrayList&lt;&gt;();
              days.add(date1);
              days.add(date2);
              days.add(date3);
              days.add(date4);
              days.add(date5);
              DayAdapter day = new DayAdapter(MainActivity.this,R.layout.layout_day_card,days,weatherDataArrayList);
              listView.setAdapter(day);
          } else {
              Log.d(TAG, "onPostExecute: no json recieved, city is Wrong");
              Toast toast = Toast.makeText(MainActivity.this,"Please provide a valid city!",Toast.LENGTH_LONG);
              toast.show();
          }
      }
  
  }
  } 
  
  WeatherAdapter : 
  public class WeatherAdapter extends ArrayAdapter&lt;WeatherData&gt; {
  private static final String TAG = "WeatherAdapter";
  private final int layoutResourceID;
  private LayoutInflater layoutInflater;
  private ArrayList&lt;WeatherData&gt; block;
  
  public WeatherAdapter(@NonNull Context context, int resource, ArrayList&lt;WeatherData&gt; block) {
      super(context, resource, block);
      this.layoutResourceID = resource;
      this.block = block;
      this.layoutInflater = LayoutInflater.from(context);
      Log.d(TAG, "WeatherAdapter: called constructor");
  }
  
  @NonNull
  @Override
  public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
      if(convertView == null){
          convertView = layoutInflater.inflate(layoutResourceID,parent,false);
      }
      Log.d(TAG, "getView: entered");
      WeatherData weatherData = block.get(position);
      TextView temp = (TextView) convertView.findViewById(R.id.temperature);
      temp.setText(weatherData.getTemp());
      TextView shortDesc = (TextView) convertView.findViewById(R.id.descrip);
      shortDesc.setText(weatherData.getShortDesc());
      return convertView;
  }
  }
  
  DayAdapter : 
  public class DayAdapter extends ArrayAdapter&lt;String&gt; {
  private static final String TAG = "DayAdapter";
  private ArrayList&lt;String&gt; dayBlock;
  private LayoutInflater layoutInflater;
  private int layoutresourceID;
  private ArrayList&lt;WeatherData&gt; dayWeather, fullBlock;
  private Context context;
  JsonToWeatherData json = new JsonToWeatherData();
  
  public DayAdapter(@NonNull Context context, int resource, @NonNull ArrayList&lt;String&gt; dayBlock, ArrayList&lt;WeatherData&gt; weatherBlock) {
      super(context, resource, dayBlock);
      this.context = context;
      this.dayBlock = dayBlock;
      this.fullBlock = weatherBlock;
      layoutInflater = LayoutInflater.from(context);
      this.layoutresourceID = resource;
      if(fullBlock == null){
          Log.e(TAG, "DayAdapter: full block is null");
      }
  }
  
  @NonNull
  @Override
  public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
      if (convertView == null){
          convertView = layoutInflater.inflate(layoutresourceID,parent,false);
      }
      TextView date = (TextView) convertView.findViewById(R.id.date);
      TextView minTempFoDay = (TextView) convertView.findViewById(R.id.minTempOfDay);
      TextView maxTempFoDay = (TextView) convertView.findViewById(R.id.maxTempOfDay);
      ListView weatherHolderListView = (ListView) convertView.findViewById(R.id.wHoldLV);
      String dateString = dayBlock.get(position);
      dayWeather = json.extractByDate(fullBlock,dateString);
      if(fullBlock == null){
          Log.d(TAG, "getView: fullblock is null");
      }
      if(dayWeather == null){
          Log.d(TAG, "getView: dayweather array is null");
      } else {
          Log.d(TAG, "getView: dayweather is not null");
      }
      String test = dayWeather.get(position).getTemp(); // error occured here
      Log.d(TAG, "getView: test string : " + test);
      date.setText(dateString);
      DecimalFormat df = new DecimalFormat(".##");
      float mint = 500, maxt = 0;
      String mint1 = "", maxt1 = "";
      for(WeatherData data : dayWeather){
          if(mint &gt; Float.parseFloat(data.getMinTemp())){
              mint = Float.parseFloat(data.getMinTemp());
              mint1 = df.format(mint);
              Log.d(TAG, "getView: mint : " + mint);
          }
          if (maxt &gt; Float.parseFloat(data.getMaxTemp())){
              maxt = Float.parseFloat(data.getMaxTemp());
              maxt1 = df.format(maxt);
          }
      }
      minTempFoDay.setText(mint1);
      maxTempFoDay.setText(maxt1);
      WeatherAdapter weatherAdapter = new WeatherAdapter(context,R.layout.weather_holder,dayWeather);
      weatherHolderListView.setAdapter(weatherAdapter);
  
      return convertView;
  }
  }
  
  JsonToWeatherData:
  public class JsonToWeatherData {
  private static final String TAG = "JsonToWeatherData";
  
  public ArrayList&lt;WeatherData&gt; extractor(String jsonData){
      Log.d(TAG, "extractor: in the method");
      if(jsonData == null){
          return null; // if there is no json data is received
      } else {
          ArrayList&lt;WeatherData&gt; weatherDataArrayList = new ArrayList&lt;WeatherData&gt;();
          Log.d(TAG, "extractor: in the else field");
          try{
              Log.d(TAG, "extractor: in try block");
              JSONObject root = new JSONObject(jsonData);
              int count = root.getInt("cnt");
              JSONArray wList = root.getJSONArray("list");
              for (int i = 0; i &lt; count; ++i){
                  WeatherData weather = new WeatherData();
                  JSONObject wBlock = wList.getJSONObject(i);
                  weather.setDate(wBlock.getString("dt_txt"));
                  JSONObject mainObj = wBlock.getJSONObject("main");
                  weather.setTemp(String.valueOf(mainObj.getDouble("temp")));
                  weather.setMinTemp(String.valueOf(mainObj.getDouble("temp_min")));
                  weather.setMaxTemp(String.valueOf(mainObj.getDouble("temp_max")));
                  weather.setHumidity(String.valueOf(mainObj.getInt("humidity")));
                  JSONArray warray = wBlock.getJSONArray("weather");
                  JSONObject weatherObj = warray.getJSONObject(0);
                  weather.setDescription(weatherObj.getString("description"));
                  weather.setShortDesc(weatherObj.getString("main"));
                  weather.setIconID(weatherObj.getString("icon"));
                  weatherDataArrayList.add(weather);
                  Log.d(TAG, "extractor: temp field is :" + weather.getTemp());
              }
          }catch (JSONException e){
              e.printStackTrace();
          }
          return weatherDataArrayList;
      }
  }
  
  public ArrayList&lt;WeatherData&gt; extractByDate(ArrayList&lt;WeatherData&gt; fullList,String date){
      ArrayList&lt;WeatherData&gt; dayweatherList = new ArrayList&lt;WeatherData&gt;();
      for( WeatherData weather : fullList ){
          if( ( weather.getDate().substring(0,9) ).equals(date) ){
              dayweatherList.add(weather);
          }
      }
      return dayweatherList;
  }
  }
  </code></pre>
  
  <p>What should I do?</p>
  
  <p>Error message : (
          08-19 23:11:39.914 12148-12148/com.jugalmistry.apps.fivedaysofweather D/DayAdapter: getView: dayweather is not null
      08-19 23:11:39.916 12148-12148/com.jugalmistry.apps.fivedaysofweather D/AndroidRuntime: Shutting down VM
      08-19 23:11:39.918 12148-12148/com.jugalmistry.apps.fivedaysofweather E/AndroidRuntime: FATAL EXCEPTION: main
          Process: com.jugalmistry.apps.fivedaysofweather, PID: 12148
          java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
              at java.util.ArrayList.get(ArrayList.java:411)
              at com.jugalmistry.apps.fivedaysofweather.DayAdapter.getView(DayAdapter.java:58)</p>