android - 如何使用 Volley 请求在 android 中执行无限滚动

标签 android android-listview android-volley infinite-scroll

我在一个 Activity 中有一个 ListView ,它呈现从 JSON 响应中获得的列表值。我能够成功地显示 ListView ,代码如下所示

listView = (ListView) findViewById(R.id.list);
        adapter = new CustomListAdapter(this, productList);
        listView.setAdapter(adapter);



        pDialog = new ProgressDialog(this);
        // Showing progress dialog before making http request
        pDialog.setMessage("Loading...");
        pDialog.show();

        GsonRequest<Product[]> getPersons =
                new GsonRequest<Product[]>(Request.Method.GET,url, Product[].class,

                        requestSuccessListener(), requestErrorListener());

        AppController.getInstance().addToRequestQueue(getPersons);

现在,当用户滚动到 ListView 的末尾时,我想通过另一个 REST 调用加载更多详细信息。请帮助我了解如何执行此操作,以便适配器中以前的数据不应该被更改并且现在应该附加在它下面。

提前致谢。

最佳答案

无限滚动请引用此处 https://github.com/codepath/android_guides/wiki/Endless-Scrolling-with-AdapterViews-and-RecyclerView .. 对于每个 customLoadMoreDataFromApi(page) 调用将数据加载到适配器并调用通知数据集已更改..

关于android - 如何使用 Volley 请求在 android 中执行无限滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30160596/

相关文章:

android - 关于 Android 中高性能绘图的提示

android - 如何更新 ListView 项目中的进度条

android - 为什么 Android-Volley 更快

android - 通过 Volley 无法使用 POST 将数据发送到服务器

java - Retrofit 2 API 我可以使用本地文件路径或 json 字符串而不是 url 吗?

javascript相关API发送短文本

java - 循环TextView并设置大小

android - 选择 ListView 项时更改 TextView 的字体颜色

android - onListItemClick 不适用于自定义 ListView

java - Android (Java) HttpURLConnection 静默重试 'read' 超时