title: How to create a Pull-to-Refresh into a listView
body: <p>Hey guys i am trying to iumplement those projects </p>
  
  <pre><code>https://github.com/erikwt/PullToRefresh-ListView
  https://github.com/johannilsson/android-pulltorefresh
  https://github.com/chrisbanes/Android-PullToRefresh
  </code></pre>
  
  <p>i have tried all three but i dont seem to be doing it correctly. can anybody help me??</p>
  
  <p>My code is:</p>
  
  <pre><code>private class JsonReadTask extends AsyncTask&lt;String, Void, String&gt; {
          @Override
          protected void onPreExecute() {
              super.onPreExecute();
              pDialog = new ProgressDialog(MainActivity.this);
              pDialog.setTitle(R.string.waiting);
              pDialog.setMessage(getString(R.string.get_stocks));
              pDialog.setCancelable(false);
              pDialog.show();
          }
          @Override
          protected String doInBackground(String... params) {
              HttpClient httpclient = new DefaultHttpClient();
              HttpPost httppost = new HttpPost(params[0]);
              try {
                  HttpResponse response = httpclient.execute(httppost);
                  jsonResult = inputStreamToString(
                          response.getEntity().getContent()).toString();
              }
  
              catch (ClientProtocolException e) {
                  e.printStackTrace();
              } catch (IOException e) {
                  e.printStackTrace();
              }
              return null;
          }
          private StringBuilder inputStreamToString(InputStream is) {
              String rLine = "";
              StringBuilder answer = new StringBuilder();
              BufferedReader rd = new BufferedReader(new InputStreamReader(is));
              try {
                  while ((rLine = rd.readLine()) != null) {
                      answer.append(rLine);
                  }
              }
              catch (IOException e) {
                  // e.printStackTrace();
                  Toast.makeText(getApplicationContext(),
                          "Error..." + e.toString(), Toast.LENGTH_LONG).show();
              }
              return answer;
          }
          @Override
          protected void onPostExecute(String result) {
              ListDrwaer();
              pDialog.dismiss();
          }
      }// end async task
      public void accessWebService() {
          JsonReadTask task = new JsonReadTask();
          // passes values for the urls string array
          task.execute(new String[] { url });
      }
      // build hash set for list view
      public void ListDrwaer() {
          List&lt;Map&lt;String, String&gt;&gt; stocksList = new ArrayList&lt;Map&lt;String, String&gt;&gt;();
          try {
              JSONObject jsonResponse = new JSONObject(jsonResult);
              JSONArray jsonMainNode = jsonResponse.optJSONArray("metoxes");
              for (int i = 0; i &lt; jsonMainNode.length(); i++) {
                  JSONObject jsonChildNode = jsonMainNode.getJSONObject(i);
                  String name = jsonChildNode.optString("name");
                  String price = jsonChildNode.optString("price");
                  stocksList.add(createStockList(name, price));
              }
  
  
          } catch (JSONException e) {
              Toast.makeText(getApplicationContext(), "Error" + e.toString(),
                      Toast.LENGTH_SHORT).show();
          }
          String[] from = { "name", "price"};
          int[] to = { R.id.stock_name, R.id.stock_price };
          SimpleAdapter simpleAdapter = new SimpleAdapter(this, stocksList,
                  R.layout.list_item,
                  from, to);
          listView.setAdapter(simpleAdapter);
      }
      private HashMap&lt;String, String&gt; createStockList(String name, String price) {
          HashMap&lt;String, String&gt; stockNameNo = new HashMap&lt;String, String&gt;();
          stockNameNo.put("name", name);
          stockNameNo.put("price", price);
          return stockNameNo;
      }
  }
  </code></pre>
  
  <p>and my layout file is</p>
  
  <pre><code>&lt;uk.co.senab.actionbarpulltorefresh.extras.actionbarsherlock.PullToRefreshLayout&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="#9FA5A4"
      android:layout_weight="1"
      android:shape="rectangle"
      android:orientation="vertical"
      tools:context=".MainActivity" &gt;
  
      &lt;ListView
          android:id="@+id/listView1"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:drawSelectorOnTop="true"
          android:layout_alignParentStart="true"
          android:dividerHeight="2dp"
          android:divider="@drawable/list_grad"
          android:layout_alignParentEnd="true" &gt;
  
      &lt;/ListView&gt;
  
  &lt;/LinearLayout&gt;
  /&gt;
  </code></pre>
  
  <p>any help will be much appreaciated. i am new to this so please help me.</p>