欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android 開(kāi)發(fā)中Volley詳解及實(shí)例

 更新時(shí)間:2017年04月06日 08:59:01   投稿:lqh  
這篇文章主要介紹了Android 開(kāi)發(fā)中Volley詳解及實(shí)例的相關(guān)資料,需要的朋友可以參考下

Android 開(kāi)發(fā)中Volley詳解及實(shí)例

最近在做項(xiàng)目的時(shí)候,各種get和post。簡(jiǎn)直要瘋了,我這種啥都不了解的,不知道咋辦了,然后百度看了下,可以用volley進(jìn)行網(wǎng)絡(luò)請(qǐng)求與獲取,下面就介紹下volley的用法。

volley有三種方式:JsonObjectRequest,JsonArrayRequest,StringRequest。其實(shí)都是差不多了,舉一反三就ok了,這里我就講下JsonObjectRequest。

方法如下:

 JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Method.POST,null,Listener,ErrListener);

事例如下:

RequestQueue myQueue = Volley.newRequestQueue(getContext());
    Map<String, String> params = new HashMap<String, String>();
    params.put("dataStr", "2016/3/18");
    params.put("selectRow", "0");
    JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, url, new JSONObject(params),new Response.Listener<JSONObject>() {

      public void onResponse(JSONObject jsonObject) {
        try {
          time.setText(jsonObject.optJSONObject("data").getString("CreateTime"));
          title.setText(jsonObject.optJSONObject("data").getString("Title"));
        } catch (Exception e) {
          e.printStackTrace();
        }
      }

    }, new Response.ErrorListener() {
      public void onErrorResponse(VolleyError volleyError) {
        Log.e("error", volleyError + "");
      }
    }) ;
    jsonObjectRequest.setTag("tag");
    myQueue.add(jsonObjectRequest);

這樣就解決了。。我可以說(shuō)因?yàn)檫@個(gè),我從周五的下午忙到現(xiàn)在嘛….好了,你們可以試下能不能解決你現(xiàn)在的問(wèn)題。

感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!

相關(guān)文章

最新評(píng)論