title: where to put android.support.v4.widget.SwipeRefreshLayout and how to implement it?
body: <p>just wanna ask where to put the android.support.v4.widget.SwipeRefreshLayout on my codes? I'm confused if it should be on my activity_main.xml or in my list_item.xml file..</p>
  
  <p>Here is my activity_main.xml:</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:orientation="vertical" &gt;
          &lt;ListView
              android:id="@+android:id/list"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"/&gt;
      &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>And This is my List_item.xml:</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;LinearLayout  xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:orientation="vertical"
          android:padding="10dp"
          android:paddingLeft="10dp"
          android:paddingRight="10dp"&gt;
  
          &lt;TextView
              android:id="@+id/datetime"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:paddingBottom="2dip"
              android:paddingTop="6dip"
              android:textColor="#43bd00"
              android:textSize="16sp"
              android:textStyle="bold" 
              android:layout_weight="1" /&gt;
  
          &lt;TextView
              android:id="@+id/qname"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:paddingBottom="2dip"
              android:textColor="#acacac" 
              android:layout_weight="1" /&gt;
  
          &lt;TextView
              android:id="@+id/qagent"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:paddingBottom="2dip"
              android:textColor="#acacac" 
              android:layout_weight="1" /&gt;
  
          &lt;TextView
              android:id="@+id/qevent"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:paddingBottom="2dip"
              android:textColor="#acacac" 
              android:layout_weight="1" /&gt;
  
          &lt;TextView
              android:id="@+id/info1"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:paddingBottom="2dip"
              android:textColor="#acacac" 
              android:layout_weight="1" /&gt;
  
          &lt;TextView
              android:id="@+id/info2"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:paddingBottom="2dip"
              android:textColor="#acacac"
              android:layout_weight="1"  /&gt;
  
          &lt;TextView
              android:id="@+id/info3"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:paddingBottom="2dip"
              android:textColor="#acacac" 
              android:layout_weight="1" /&gt;  
      &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>I Found some sample codes on the internet where they put it on the main xml but some samples also put it on the list xml..</p>
  
  <p>This is my Main activity : </p>
  
  <pre><code>import java.util.ArrayList;
  import java.util.HashMap;
  
  import org.json.JSONArray;
  import org.json.JSONException;
  import org.json.JSONObject;
  
  import android.app.Fragment;
  import android.app.ListActivity;
  import android.app.ProgressDialog;
  import android.os.AsyncTask;
  import android.os.Bundle;
  import android.util.Log;
  import android.widget.ListAdapter;
  import android.widget.ListView;
  import android.widget.SimpleAdapter;
  
  
  public class MainActivity extends ListActivity {
  
      private ProgressDialog pDialog;
      private static String IPaddress = "http://192.168.1.110/";
  
      // URL to get contacts JSON
      private static String url = IPaddress + "Projects/GetUsers.php";
  
  
      private static final String TAG_QUEUE = "queue"; 
      private static final String TAG_DATETIME = "datetime";
      private static final String TAG_NAME = "qname"; 
      private static final String TAG_AGENT = "qagent"; 
      private static final String TAG_EVENT = "qevent";
      private static final String TAG_INFO1 = "info1";
      private static final String TAG_INFO2 = "info2";
      private static final String TAG_INFO3 = "info3";
  
  
      // contacts JSONArray
      JSONArray queue = null;
  
      // Hashmap for ListView
      ArrayList&lt;HashMap&lt;String, String&gt;&gt;queueList;
  
  
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          queueList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
  
        //  ListView lv = getListView();
  
  
  
  
  
          // Calling async task to get json
          new GetEventCounter().execute();
      }
  
      /**
       * Async task class to get json by making HTTP call
       * */
      private class GetEventCounter extends AsyncTask&lt;Void, Void, Void&gt; {
  
          @Override
          protected void onPreExecute() {
              super.onPreExecute();
              // Showing progress dialog
              pDialog = new ProgressDialog(MainActivity2.this);   
              pDialog.setMessage("Please wait...");
              pDialog.setCancelable(false);
              pDialog.show();
  
          }
  
  
  
  
          @Override
          protected Void doInBackground(Void... arg0) {
              // Creating service handler class instance
              ServiceHandler sh = new ServiceHandler();
  
              // Making a request to url and getting response
              String jsonStr = sh.makeServiceCall(url, ServiceHandler.GET);
  
              Log.d("Response: ", "&gt; " + jsonStr);
  
              if (jsonStr != null) {
                  try {
                      JSONObject jsonObj = new JSONObject(jsonStr);
  
  
                      queue = jsonObj.getJSONArray(TAG_QUEUE);
  
  
                      for (int i = 0; i &lt; queue.length(); i++) {
                          JSONObject c = queue.getJSONObject(i);           
  
                          String datetime = String.format("%s : %s", TAG_DATETIME, c.getString(TAG_DATETIME));
                          String qname = String.format("%s : %s", TAG_NAME, c.getString(TAG_NAME));
                          String qagent = String.format("%s : %s", TAG_AGENT, c.getString(TAG_AGENT));
                          String qevent = String.format("%s : %s", TAG_EVENT, c.getString(TAG_EVENT));
                          String info1 = String.format("%s : %s", TAG_INFO1, c.getString(TAG_INFO1));
                          String info2 = String.format("%s : %s", TAG_INFO2, c.getString(TAG_INFO2));
                          String info3 = String.format("%s : %s", TAG_INFO3, c.getString(TAG_INFO3));
  
  
  
  
  
                          HashMap&lt;String, String&gt; event = new HashMap&lt;String, String&gt;();
  
  
                          event.put(TAG_DATETIME, datetime);
                          event.put(TAG_NAME, qname);
                          event.put(TAG_AGENT, qagent);
                          event.put(TAG_EVENT, qevent);
                          event.put(TAG_INFO1, info1);
                          event.put(TAG_INFO2, info2);
                          event.put(TAG_INFO3, info3);
  
  
  
                          queueList.add(event);
                      }
                  } catch (JSONException e) {
                      e.printStackTrace();
                  }
              } else {
                  Log.e("ServiceHandler", "Couldn't get any data from the url");
              }
  
              return null;
          }
  
          @Override
          protected void onPostExecute(Void result) {
              super.onPostExecute(result);
              // Dismiss the progress dialog
              if (pDialog.isShowing())
                  pDialog.dismiss();
              /**
               * Updating parsed JSON data into ListView
               * */
              ListAdapter adapter = new SimpleAdapter(
                      MainActivity2.this, queueList,
                      R.layout.list_item, new String[] { TAG_DATETIME, TAG_NAME, TAG_AGENT, TAG_EVENT, TAG_INFO1, TAG_INFO2, TAG_INFO3}, 
                      new int[] { R.id.datetime, R.id.qname, R.id.qagent, R.id.qevent, R.id.info1, R.id.info2, R.id.info3 });
  
              setListAdapter(adapter);
          }
  
  
  
      }
  
  
  
  
      protected Fragment getSampleFragment() {
          // TODO Auto-generated method stub
          return null;
      }
  
  }
  </code></pre>
  
  <p>This will be the output that i want to have an SwipeRefresh effect..
  Those output came from MySQL Database : </p>
  
  <p><a href="https://i.stack.imgur.com/F3jdW.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/F3jdW.jpg" alt="enter image description here"></a></p>
  
  <p>This samples caused my confusion </p>
  
  <pre><code>&lt;android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/swype"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
      &lt;ListView
          android:id="@+id/list"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" /&gt;
  
  &lt;/android.support.v4.widget.SwipeRefreshLayout&gt;
  </code></pre>
  
  <p>And : </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/swype"
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="horizontal"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"&gt;
  
      &lt;TextView
          android:id="@+id/serial"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:padding="25dp"
          android:layout_margin="5dp"
          android:layout_alignParentLeft="true"
          android:textSize="20dp"
          android:textStyle="bold" /&gt;
  
      &lt;TextView
          android:id="@+id/title"
          android:layout_toRightOf="@id/serial"
          android:layout_centerVertical="true"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:textStyle="bold"
          android:paddingLeft="20dp"
          android:textSize="18dp" /&gt;
  
  &lt;/RelativeLayout&gt;
  &lt;/android.support.v4.widget.SwipeRefreshLayout&gt;
  </code></pre>
  
  <p>Thanks!</p>