java - When i want add a object from request json in an ArrayList -


well, consult json object url , object , add string, there right, problem when add arraylist line skipped , not executed when add , know why?

public void consult(string val_user){      jsonarrayrequest jsonarrayrequest = new jsonarrayrequest(             "http://"+ippref+":8080/activo/webresources/activo.entities.historialactivos/consulta/"+val_user+"", new response.listener<jsonarray>() {         @override         public void onresponse(jsonarray response) {              string item = "";             (int = 0; < response.length(); i++) {                 try {                      jsonobject obj = response.getjsonobject(i);                      item += "actividad: " + obj.getstring("actividad") + "\r\n";                     item += "activo ns: " + obj.getstring("activo") + "\r\n";                     item += "fecha: " + obj.getstring("fecha") + "\r\n";                     item += "id activo: " + obj.getstring("idactivo") + "\r\n";                     item += "id historial: " + obj.getstring("idhistorialactivo") + "\r\n";                     item += "id incidencia: " + obj.getstring("idincidencia") + "\r\n";                     item += "id usuario: " + obj.getstring("idusuario") + "\r\n";                     item += "incidencia: " + obj.getstring("incidencia") + "\r\n";                     item += "observaciones: " + obj.getstring("observaciones") + "\r\n";                     item += "oficina: " + obj.getstring("oficina") + "\r\n";                     item += "tipo de movimiento: " + obj.getstring("tipomovimiento") + "\r\n";                     item += "usuario: " + obj.getstring("usuario" + "\r\n");                      array.add(item);                      item = "";                   } catch (jsonexception ex) {                     ex.printstacktrace();                 }                 metodo_adapter();                 adapter.notifydatasetchanged();              }         }      }, new response.errorlistener() {         @override         public void onerrorresponse(volleyerror error) {          }     });     appcontroller.getinstance().addtorequestqueue(jsonarrayrequest); } 

in array.add(item) when execute debug skip line of code.

array.add(item); item = ""; // line causing issue. 

don't make item string empty because string reference based variable , if end storing " " in array.

better define string item = ""; inside try block


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -