Guest User

Untitled

a guest
Dec 12th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. public void onResponse(JSONObject response) {
  2.  
  3. JSONArray json = response.optJSONArray("prePedido");
  4. JSONObject jsonObject = null;
  5. try {
  6. int i = 0;
  7. for(i=0; i<json.length();i++){
  8. prePedido PrePedido = new prePedido();
  9. jsonObject = json.getJSONObject(i);
  10. PrePedido.setNombre_producto(jsonObject.optString("nombre"));
  11. PrePedido.setPrecio(jsonObject.optDouble("precio"));
  12. PrePedido.setIdCliente(jsonObject.optInt("idCliente"));
  13. PrePedido.setIdProducto(jsonObject.optInt("idProducto"));
  14. PrePedido.setIdRestaurant(jsonObject.optInt("idRestaurant"));
  15. PrePedido.setId(jsonObject.optInt("idPrePedido"));
  16. precio = jsonObject.optDouble("precio")+precio;
  17. pedidos.add(PrePedido);
  18. }
  19. adapter = new PrePedidoAdapter(this, pedidos, usuario);
  20. lista.setAdapter(adapter);
  21. total.setText("El total es: $"+String.valueOf(precio)+'0');
  22.  
  23. } catch (JSONException e) {
  24. e.printStackTrace();
  25. }
  26. }
Add Comment
Please, Sign In to add comment