Advertisement
taisonik

Untitled

Jul 20th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.18 KB | None | 0 0
  1. JsonObjectRequest jsonObjReq= new JsonObjectRequest(Method.GET, urlPedido, null, new Response.Listener<JSONObject>(){
  2.             @Override
  3.             public void onResponse(JSONObject response) {
  4.                 //para convertir JSON a objeto:
  5.                 Empleado emp= gson.fromJson(response, Empleado.class);
  6.  
  7.                 txtDireccion.setText("Address: "+emp.getAddress());
  8.                 txtTipoSangre.setText("BloodGroup: "+emp.getBloodGroup());
  9.                 txtCodigoEmpleado.setText("EmployeeId: "+emp.getEmployeeId());
  10.                 txtNombre.setText("FirstName: "+emp.getFirstName());
  11.                 txtApellido.setText("LastName: "+emp.getLastName());
  12.                 pDialog.hide();
  13.                 txtError.setText("");
  14.             }//Fin onResponse
  15.  
  16.         }, new Response.ErrorListener(){
  17.  
  18.             @Override
  19.             public void onErrorResponse(VolleyError error) {
  20.                 VolleyLog.d(TAG,"Error: "+error.getMessage());
  21.                 txtError.setText("Error no se encuentra ");
  22.                 pDialog.hide();
  23.             }
  24.         });
  25.         //agregar el request a la cola de request
  26.         Volley.newRequestQueue(getApplicationContext()).add(jsonObjReq);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement