gpt4 book ai didi

android - 下拉刷新示例,Eclipse 找不到 setOnRefreshListener 命令

转载 作者:太空狗 更新时间:2023-10-29 12:47:15 24 4
gpt4 key购买 nike

我正在处理来自 Git-hub 的众所周知的下拉刷新示例

我加载了库并且一切正常,但是当我想调用方法 setOnRereshListener 时,Eclipse 找不到它。可能是什么问题?

这是例子中的代码:

        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();
}
});

这是我的代码:

public class MainActivity extends Activity {
private static final String URL = "http://192.168.1.103/php-android/testphp.php";
private static final String TAG_DATA = "data";
private static final String TAG_ID = "name";
private static final String TAG_DATE = "date";
public PullToRefreshListView listView;
JSONArray data = null;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder() .detectAll().penaltyLog().build();
StrictMode.setThreadPolicy(policy);
getDataInArray();

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();
}
});
}

最佳答案

不确定,但我相信这是由于方法签名 OnRefresh (PullToRefreshBase refreshView),尝试删除 PullToRefreshBase refreshView,如下所示:

pullToRefreshView.setOnRefreshListener(new OnRefreshListener() {
@Override
public void onRefresh() {
// Do work to refresh the list here.

new GetDataTask().execute();
}
});

我在没有签名方法 OnRefresh () 的情况下使用了相同的结构,它工作正常。

关于android - 下拉刷新示例,Eclipse 找不到 setOnRefreshListener 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16739604/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com