2014-04-10 108 views
0

這是我的佈局xml。如何滾動拉動以在正常滾動視圖中刷新滾動視圖

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/garae_scroll" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:background="@color/background" 
android:fillViewport="true" 
android:focusableInTouchMode="false" > 
    <RelativeLayout> 
     ... 
     <com.handmark.pulltorefresh.library.PullToRefreshScrollView> 
     <LinearLayout/> 
     </com.handmark.pulltorefresh.library.PullToRefreshScrollView> 
    </RelativeLayout> 
</ScrollView> 

我已經嘗試過在這個環節的解決方案: ScrollView Inside ScrollView

然而,它沒有工作。如何使用子PullToRefreshScrollView? 請幫幫我。

回答

6

如果我理解你的問題,你想實現一個拉動你的滾動查看刷新。相反,要使用您使用的庫,我建議您實施SwipeRefreshLayout,而不是使用SwipeRefreshLayout https://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.html 這是一種佈局,可以像在應用程序Google+或Gmail中一樣實現拉到即刷新。

Here an example of how to implement the SwipeRefreshLayout in your xml : 

    <?xml version="1.0" encoding="utf-8"?> 

    <FrameLayout 
     android:layout_width="match_parent" android:layout_height="match_parent" 
     xmlns:android="http://schemas.android.com/apk/res/android" > 

     <android.support.v4.widget.SwipeRefreshLayout 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:id="@+id/swipe_container" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 

      <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
      xmlns:tools="http://schemas.android.com/tools" 
      android:id="@+id/garae_scroll" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" > 

     </ScrollView> 

     </android.support.v4.widget.SwipeRefreshLayout> 
</FrameLayout> 

注意

強烈不建議把一個滾動型/列表視圖滾動型/列表視圖中。第一個原因是關於性能和羅曼蓋解釋,在一個視頻https://www.youtube.com/watch?v=wDBM6wVEO70

+0

感謝雨果我檢查了這麼多的例子,但沒有提到,我們需要實現查詢偵聽器。 – dharmesh

相關問題