2

I have an app for getting the RSS feeds and I am trying to implement pull to refresh. I took reference from https://github.com/johannilsson/android-pulltorefresh. Can anyone help to include this in eclipse? Do we have jars for this?

4

2 回答 2

2

请按照以下步骤操作:

在 Eclipse 中执行File -> New -> other(不要使用File->new->Android application project)并选择"Android Project from existing code"

单击下一步,然后浏览到具有pulltorefresh库的目录 - 如果要将文件复制到工作区,请选中项目列表框下的复选框。然后单击完成按钮。

重复刚才的操作,但这次选择 pulltorefreshexample 目录。

确保这两个项目都是打开的,然后在包资源管理器中选择 pulltorefreshexample,右键单击它并选择属性。在出现的窗口中选择左侧的 Android,然后在最底部有一个“库”部分。单击添加,您应该会看到一个包含所有打开的库项目的列表。选择 pulltorefresh 之一。

清理并构建库,然后清理并构建示例。

于 2013-01-15T07:08:39.127 回答
0

您可以参考视频和页面(带有代码)来实现它,因为在 android 中还没有直接控制它

一些片段:在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" />

关于活动:

// 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);
    }
}
于 2013-01-15T07:05:14.750 回答