I have a json that gives me this result:
{
"error": false,
"fatigas": [
{
"fatServ_fecha": "2018-01-07",
"fatServ_HoraIn": "10:13:00",
"fatServ_HoraOut": null,
"turn_cod": "3",
"are_cod": "62",
"fatServ_cerrar": "D",
"fatServ_imprimir": "D",
"fatServ_validacion": "D"
}
]
}
and here is the code where I printed it, the problem is that it does not enter the for
protected void onPostExecute(String s) {
super.onPostExecute(s);
((Activity) getContext()).runOnUiThread(new Runnable() {
@Override
public void run() {
try {
if(jsonObject!=null){
items = new ArrayList<>();
JSONArray resultados = jsonObject.getJSONArray("respuesta");
for (int i = 0; i < resultados.length(); i++) {
JSONObject fatigas = resultados.getJSONObject(i);
items.add(new Fatigas(fatigas.getString("fatServ_fecha")+"",
fatigas.getString("fatServ_HoraIn")+"",
fatigas.getString("fatServ_HoraOut")+"",
fatigas.getString("turn_cod")+"",
fatigas.getString("are_cod")+"",
fatigas.getString("fatServ_cerrar"),
fatigas.getString("fatServ_imprimir"),
fatigas.getString("fatServ_validacion")));
}
} else {
Toast.makeText(getContext(),"No hay fatigas",Toast.LENGTH_LONG).show();
}
} catch (JSONException e) {
e.printStackTrace();
}
FatigasAdapter adapter = new FatigasAdapter(items);
rv_listado.setAdapter(adapter);
rv_listado.setLayoutManager(new GridLayoutManager(getContext(),1));
}
});
}