我已经解决了这个问题,但是忘记写了:)
我的layout.xml 文件如下所示:
<com.handmark.pulltorefresh.library.PullToRefreshScrollView
android:id="@+id/home_info_pulltorefresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true" >
<LinearLayout
android:id="@+id/home_info_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white_background"
android:baselineAligned="false"
android:orientation="horizontal" >
<LinearLayout
android:id="@+id/charts_container"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:orientation="vertical"
android:paddingRight="5dp" >
<FrameLayout
android:id="@+id/frame_container_chart_top"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<FrameLayout
android:id="@+id/frame_container_chart_bottom"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
<FrameLayout
android:id="@+id/frame_container_right"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
</com.handmark.pulltorefresh.library.PullToRefreshScrollView>
android:fillViewport="true" 用于拉伸其内容以填充视口(使滚动高度匹配父项)
我以编程方式添加包含 ListView 的 Fragment(R.layout.frame_container_rightFragment 资源 ID)
一切正常,但是当我尝试向下滚动 ListView 时,我的 ScrollView 开始滚动。向上滚动 ListView 工作正常。我还注意到,如果我点击 ListView,向左或向右移动手指然后尝试向下滚动,触摸事件不会从 ListView 传输到 ScrollView,我会得到预期的行为。所以我决定以编程方式模拟这种情况:
mListViewReviews.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
long startTime = SystemClock.uptimeMillis();
long duration = 1;
MotionEvent e = MotionEvent.obtain(startTime, startTime + duration, MotionEvent.ACTION_MOVE, event
.getX(), event.getY() + 10, 0);
MotionEvent ev = MotionEvent.obtain(startTime + duration, startTime + duration * 2,
MotionEvent.ACTION_MOVE, event.getX(), event.getY() + 20, 0);
v.dispatchTouchEvent(e);
v.dispatchTouchEvent(ev);
}
return false;
}
});
因此,我可以使用具有适当单元重用和下拉刷新逻辑的 ListView。谢谢!