【发布时间】:2018-01-03 02:39:01
【问题描述】:
我已经实现了SwipeRefreshLayout,它基本上工作正常。 https://developer.android.com/training/swipe/add-swipe-interface.html
当您转到列表底部并尝试滚动到顶部 SwipeRefreshLayout 刷新时,我遇到了奇怪的问题。
这不是我需要的。我只需要滚动到 List 的顶部,而不是刷新 ListView。
我的意思是,根据我们所处的位置,刷新时间应该是某种条件。对?因为当我们在 ListView 的顶部时,预期的行为是允许刷新。
请帮忙。
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swiperefresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
<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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity"
android:orientation="vertical"
>
<SearchView
android:id="@+id/editSearch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:iconifiedByDefault="false"
android:queryHint="Input the number"
/>
<ListView
android:paddingTop="5dp"
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</android.support.v4.widget.SwipeRefreshLayout>
还有代码
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_fragment_two, container, false);
swiperefresh = (SwipeRefreshLayout) view.findViewById(R.id.swiperefresh);
swiperefresh.setColorScheme(R.color.colorPrimary, R.color.colorAccent, R.color.colorPrimaryDark, R.color.colorPrimary);
swiperefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
swiperefresh.setRefreshing(true);
Log.d("Swipe", "Refreshing Number");
// Get data from WebAPI or database cache
}
});
return view;
}
【问题讨论】:
标签: java android swiperefreshlayout