android - 如何在Android应用程序中实现下拉刷新

标签 android adt pull-to-refresh

<分区>

我有一个用于获取 RSS 提要的应用程序,我正在尝试实现下拉刷新。我引用了 https://github.com/johannilsson/android-pulltorefresh . 任何人都可以帮助将其包含在 Eclipse 中吗?我们有这个的 jar 吗?

最佳答案

可以引用this视频和this页面(带有代码)来实现它,因为在 android 中还没有直接控件

一些 fragment : 在 XML 中:

<!--
  The PullToRefresh-ListView replaces a standard ListView widget,
  and has all the features android.widget.ListView has.
-->
<eu.erikw.PullToRefreshListView
    android:id="@+id/pull_to_refresh_listview"
    android:layout_height="fill_parent"
    android:layout_width="fill_parent" />

关于 Activity :

// Set a listener to be invoked when the list should be refreshed.
PullToRefreshListView pullToRefreshView = (PullToRefreshListView) findViewById(R.id.pull_to_refresh_listview);
pullToRefreshView.setOnRefreshListener(new OnRefreshListener<ListView>() {
    @Override
    public void onRefresh(PullToRefreshBase<ListView> refreshView) {
        // Do work to refresh the list here.
        new GetDataTask().execute();
    }
});

private class GetDataTask extends AsyncTask<Void, Void, String[]> {
    ...
    @Override
    protected void onPostExecute(String[] result) {
        // Call onRefreshComplete when the list has been refreshed.
        pullToRefreshView.onRefreshComplete();
        super.onPostExecute(result);
    }
}

关于android - 如何在Android应用程序中实现下拉刷新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14332605/

相关文章:

java - 当 OOM 发生时,如何让 dalvik 转储整个应用程序堆内存

flutter - 使用 Riverpod 在 Flutter 中实现下拉刷新

android - 如何将 ChrisBanes 的 ActionBar-PullToRefresh 库与具有 GridView 的 fragment 一起使用

android - 按密度拆分的 APK 仍包含所有资源

android - 动态添加组中的菜单项android导航菜单

android - 如何指定R.java的包名与app包名不同

Android Eclipse挂起

ios - swift 4 刷新控件在上面

java - Android Studio 4.0:构建失败|请检查您是否安装了Windows Universal C Runtime

android - 在 ListView 中检查多个项目