The problem I have is that basically, when I'm going to print the data, I already have toast, or with anything it brings me null data, the particular thing is that I print the toast for the times of data that are in the json, but all the data it brings are null. Here is the fragment of the method in which I am doing the operation
RequestQueve rq;
public List<Peliculas> peliculas
public void webService(View vista){
String url = "mi url";
AlertDialog.Builder alert = new AlertDialog.Builder(this);
rq = Volley.newRequestQueue(this);
JsonArrayRequest jar = new JsonArrayRequest(Request.Method.POST, url, null, new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
Type TypeList = new TypeToken<List<Peliculas>>(){
}.getType();
peliculas = new Gson().fromJson(response.toString(), TypeList);
Toast.makeText(getApplicationContext(),"Respuesta completada con exito",Toast.LENGTH_LONG).show();
for (Peliculas pelis : peliculas){
Toast.makeText(getApplicationContext(),"ID pelicula"+pelis.getId_pelicula(), Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(),"nombre pelicula"+pelis.getNombre(), Toast.LENGTH_SHORT).show();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getApplicationContext(),"Hubo un error",Toast.LENGTH_LONG).show();
}
}){
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String,String>params = new HashMap<>();
params.put("Accept","Application/json");
return params;
}
};
rq.add(jar);
}
And the movie class
public class Peliculas {
public int getId_pelicula() {
return id_pelicula;
}
public void setId_pelicula(int id_pelicula) {
this.id_pelicula = id_pelicula;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public String getSipnosis() {
return sipnosis;
}
public void setSipnosis(String sipnosis) {
this.sipnosis = sipnosis;
}
public int getCalificacion() {
return calificacion;
}
public void setCalificacion(int calificacion) {
this.calificacion = calificacion;
}
public String getDuracion() {
return duracion;
}
public void setDuracion(String duracion) {
this.duracion = duracion;
}
public Peliculas(int id_pelicula, String nombre, String sipnosis, int calificacion, String duracion) {
this.id_pelicula = id_pelicula;
this.nombre = nombre;
this.sipnosis = sipnosis;
this.calificacion = calificacion;
this.duracion = duracion;
}
private int id_pelicula;
private String nombre;
private String sipnosis;
private int calificacion;
private String duracion;
}