小编TSB*_*99X的帖子

即使在指定 pageSize=100 后,NewsApi 也返回 totalResults=20

我在 android 应用程序中使用新闻 API

我试图从服务器获取更多的结果(新闻),但它始终只返回20个结果中的文档中提到它已经被设置为默认位置

这是我的代码:

class DownloadNews extends AsyncTask<String, Void, String> {
        @Override
        protected void onPreExecute() {
            super.onPreExecute();
        }
        protected String doInBackground(String... args) {
            String xml = "";

            String urlParameters = "";
            xml = Function.excuteGet("https://newsapi.org/v2/top-headlines?country=in&pageSize=100&apiKey=******************", urlParameters);
            return xml;
        }
        @Override
        protected void onPostExecute(final String xml) {

            if (xml != null) {
                if (xml.length() > 10) { // Just checking if not empty

                    Log.d("xml", xml);

                } else {

                }
            } else {

            }
        }

    }
Run Code Online (Sandbox Code Playgroud)

我已将 …

android android-asynctask

6
推荐指数
1
解决办法
4892
查看次数

C++ 11.Lambdas成员变量捕获,"这个"指针陷入STL列表中

我有一个带简单按钮的简单事件系统.该系统由std :: function列表驱动,内部分配了lambdas.

这是完整的按钮类:

class Button {

private:

    Square square;
    Text label;
    bool hovered = false;
    std::function <void ()> on_mouse_enter;
    std::function <void ()> on_mouse_leave;

public:

    Button (const Square& SQUARE, const Text& LABEL):
        square {SQUARE},
        label {LABEL}
    {
        on_mouse_enter = [this] () {
            square.set_color(1, 1, 1);
        };

        on_mouse_leave = [this] () {
            square.set_color(0, 0, 0);
        };
    }

    std::function <void (const Render&)> get_rendering() {
        return [this] (const Render& RENDER) {
            RENDER.draw(square);
            RENDER.draw(label);
        };
    }

    std::function <void (const Point&)> get_updating() {
        return [this] …
Run Code Online (Sandbox Code Playgroud)

c++ lambda stl c++11

3
推荐指数
1
解决办法
585
查看次数

标签 统计

android ×1

android-asynctask ×1

c++ ×1

c++11 ×1

lambda ×1

stl ×1