2014-04-10 35 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

相关问题