SwipeRefreshLayout OnRefreshListener not called when registered in onCreate
<p>I'm trying to use <code>SwipeRefreshLayout</code> but when I set the <code>OnRefreshListener</code> in the <code>onCreate()</code> method of the activity, it does not get called when swiping. Looking at the example code this does appear to be the proper way to do things. When I register the listener at a later point, like in <code>onPostCreate()</code> or at the press of a button, it does get called on swipe. What am I missing? </p>

<p><strong>MessageListActivity.java</strong>:</p>

<pre><code>@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_message_list);

    final SwipeRefreshLayout swipeLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_layout);
    swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            Log.d(TAG, "Swiped for refresh!");
        }
    });
}
</code></pre>

<p><strong>activity_message_list.xml</strong>:</p>

<pre><code>&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:gravity="center_horizontal"
    android:orientation="vertical"
    tools:context=".LoginActivity"&gt;

    &lt;android.support.v4.widget.SwipeRefreshLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/swipe_layout"&gt;
        &lt;ListView xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@android:id/list"
            android:drawSelectorOnTop="false"&gt;
        &lt;/ListView&gt;
    &lt;/android.support.v4.widget.SwipeRefreshLayout&gt;
&lt;/LinearLayout&gt;
</code></pre>