Advertisement
taisonik

Untitled

Jul 20th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 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. txtDireccion.setText("Address: "+emp.getAddress());
  7. txtTipoSangre.setText("BloodGroup: "+emp.getBloodGroup());
  8. txtCodigoEmpleado.setText("EmployeeId: "+emp.getEmployeeId());
  9. txtNombre.setText("FirstName: "+emp.getFirstName());
  10. txtApellido.setText("LastName: "+emp.getLastName());
  11. txtError.setText("");
  12. }//Fin onResponse
  13. }, new Response.ErrorListener(){
  14. @Override
  15. public void onErrorResponse(VolleyError error) {
  16. VolleyLog.d(TAG,"Error: "+error.getMessage());
  17. txtError.setText("Error no se encuentra ");
  18. }
  19. });
  20. //agregar el request a la cola de request
  21. Volley.newRequestQueue(getApplicationContext()).add(jsonObjReq);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement