我添加了编译' com.navercorp.pulltorefresh:library:3.2.3@aar'到我的build.gradle。
<com.handmark.pulltorefresh.library.PullToRefreshListView
xmlns:ptr="http://schemas.android.com/apk/res-auto"
android:id="@+id/pull_refresh_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fadingEdge="none"
android:fastScrollEnabled="false"
android:footerDividersEnabled="false"
android:headerDividersEnabled="false"
android:smoothScrollbar="true"
android:overScrollMode="never"
ptr:ptrOverScroll="false"/>
我像这样制作了我的xml。
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_example);
mPullRefreshListView = (PullToRefreshListView) findViewById(R.id.pull_refresh_list);
mPullRefreshListView
.setOnRefreshListener(new OnRefreshListener<ListView>() {
@Override
public void onRefresh(
PullToRefreshBase<ListView> refreshView) {
new ProcessTask().execute();
}
});
items = new String[31];
for (int index = 0; index <= 30; index++) {
items[index] = "list " + index;
}
mPullRefreshListView.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, items));
}
public class ProcessTask extends AsyncTask<String, Integer, Long> {
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected Long doInBackground(String... params) {
try {
Thread.sleep(2000);
Toast.makeText(getApplicationContext(), "dddd",
Toast.LENGTH_SHORT).show();
} catch (Exception e) {
return 0l;
}
return 1l;
}
@Override
protected void onPostExecute(Long result) {
super.onPostExecute(result);
mPullRefreshListView.onRefreshComplete();
}
}
pullToRefresh工作正常。但过度滚动永远不会被删除。
我浪费了6个小时试图解决这个问题。
问题是什么?