2014-03-26 87 views
1

我正在嘗試將ActionBar-PushToRefresh添加到我的項目中。我已經按照從克里斯巴內斯Github上有說明:Github ActionBar-PullToRefreshActionBar-PullToRefresh沒有任何反應

這是我的看法從中我要啓用PullToRefresh功能:

 <uk.co.senab.actionbarpulltorefresh.library.PullToRefreshLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/ptr_layout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

    <!-- Your content, here we're using a ScrollView --> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textAppearance="?android:attr/textAppearanceLarge" 
     android:text="PULLTOREFRESH THE VIEW" 
     android:id="@+id/textView1" /> 
    <ScrollView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    </ScrollView> 

</uk.co.senab.actionbarpulltorefresh.library.PullToRefreshLayout> 

,這裏是我的活動,以顯示視圖:

package com.Test.pulltorefresh; 

import android.app.Activity; 
import android.os.Bundle; 
import uk.co.senab.actionbarpulltorefresh.library.ActionBarPullToRefresh; 
import uk.co.senab.actionbarpulltorefresh.library.Options; 
import uk.co.senab.actionbarpulltorefresh.library.PullToRefreshLayout; 


public class MainActivity extends Activity { 
    private PullToRefreshLayout mPullToRefreshLayout; 

    @Override 
    public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 

    // Now find the PullToRefreshLayout to setup 
    mPullToRefreshLayout = (PullToRefreshLayout) findViewById(R.id.ptr_layout); 

    // Now setup the PullToRefreshLayout 
    ActionBarPullToRefresh.from(this) 
      // Mark All Children as pullable 
      .allChildrenArePullable() 
        // Set the OnRefreshListener 
      //.listener(this) 
        // Finally commit the setup to our PullToRefreshLayout 
      .setup(mPullToRefreshLayout); 
} 
} 

當我啓動我的應用程序,我得到了空白視圖,但是當我試圖PushToRefresh我的看法沒有任何反應。有人能告訴我如何解決它,我知道我錯過了一些東西。謝謝。

回答

0

我可能有點偏,但... you could consider using this

+0

謝謝我會看看它。 –

+0

但我仍然想使用ActionBar-PullToRefresh開始一個好的開發,有人可以幫助我嗎? –

0

也許你已經實現的功能,但在上面的代碼中註釋掉定義上拉視圖的動作就行了。

//.listener(this) 

您應該取消註釋此行並定義偵聽器方法,該方法在視圖被拉動時應該被調用。