2016-03-18 27 views
1
> public void makeJsonObjectRequest(Long s,Double lat, Double lon, int 
> timezone) { 
>   String urlJsonObj = "http://projet.dev.e-njaz.com/api/example/getPrayerTimes/" + s + "/" + 
> lat + "/" + lon + "/" + timezone; 
>   JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.GET, 
>     urlJsonObj, null, new Response.Listener<JSONObject>() { 
>    @Override 
>    public void onResponse(JSONObject response) { 
>     Log.d(TAG, response.toString()); 
>     try { 
>      DateFormat i=new SimpleDateFormat("HH:mm"); 
>      DateFormat o = new SimpleDateFormat("KK:mm a"); 
>      prayertimes.setStr_asarr(response.toString()); 
>      prayertimes.str_ishaa=o.format(i.parse(response.getString("6").toString())); 
>     } catch (JSONException e) { 
>      e.printStackTrace(); 
>     } catch (ParseException e) { 
>      e.printStackTrace(); 
>     } 
>    } 
> 
>   }, new Response.ErrorListener() { 
>    @Override 
>    public void onErrorResponse(VolleyError error) { 
>     VolleyLog.d(TAG, "Error: " + error.getMessage()); 
>     Toast.makeText(getApplicationContext(), 
>       error.getMessage(), Toast.LENGTH_SHORT).show(); 
>    } 
>   }); 
>   AppController.getInstance().addToRequestQueue(jsonObjReq); 
>   
>  } 

hello evrybody,我需要返回函数onReponse中的对象付款人次,请你帮我。当我改变onReponse的类型返回时,我有一个错误。我需要返回排球库的结果

回答

1

您必须使用'回调'才能从抽排中返回值。它是一个相当复杂的方法,所以我会建议一个替代方案你应该在活动中创建一个变量并在onResponse中设置它的值,然后在你想要的任何函数中使用该变量(你甚至可以在o​​nResponse中调用该函数)。

如果你仍然想尝试返回一个值,然后检查this

如果你不明白的东西把它留在评论

相关问题