Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void onResponse(JSONObject response) {
- JSONArray json = response.optJSONArray("prePedido");
- JSONObject jsonObject = null;
- try {
- int i = 0;
- for(i=0; i<json.length();i++){
- prePedido PrePedido = new prePedido();
- jsonObject = json.getJSONObject(i);
- PrePedido.setNombre_producto(jsonObject.optString("nombre"));
- PrePedido.setPrecio(jsonObject.optDouble("precio"));
- PrePedido.setIdCliente(jsonObject.optInt("idCliente"));
- PrePedido.setIdProducto(jsonObject.optInt("idProducto"));
- PrePedido.setIdRestaurant(jsonObject.optInt("idRestaurant"));
- PrePedido.setId(jsonObject.optInt("idPrePedido"));
- precio = jsonObject.optDouble("precio")+precio;
- pedidos.add(PrePedido);
- }
- adapter = new PrePedidoAdapter(this, pedidos, usuario);
- lista.setAdapter(adapter);
- total.setText("El total es: $"+String.valueOf(precio)+'0');
- } catch (JSONException e) {
- e.printStackTrace();
- }
- }
Add Comment
Please, Sign In to add comment