我在 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)
我已将 …
我有一个带简单按钮的简单事件系统.该系统由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)