Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- JsonObjectRequest jsonObjReq= new JsonObjectRequest(Method.GET, urlPedido, null, new Response.Listener<JSONObject>(){
- @Override
- public void onResponse(JSONObject response) {
- //para convertir JSON a objeto:
- Empleado emp= gson.fromJson(response, Empleado.class);
- txtDireccion.setText("Address: "+emp.getAddress());
- txtTipoSangre.setText("BloodGroup: "+emp.getBloodGroup());
- txtCodigoEmpleado.setText("EmployeeId: "+emp.getEmployeeId());
- txtNombre.setText("FirstName: "+emp.getFirstName());
- txtApellido.setText("LastName: "+emp.getLastName());
- txtError.setText("");
- }//Fin onResponse
- }, new Response.ErrorListener(){
- @Override
- public void onErrorResponse(VolleyError error) {
- VolleyLog.d(TAG,"Error: "+error.getMessage());
- txtError.setText("Error no se encuentra ");
- }
- });
- //agregar el request a la cola de request
- Volley.newRequestQueue(getApplicationContext()).add(jsonObjReq);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement