spinner.setOnItemSelectedListener(new AdapterView.OnIte
@Override
public void onItemSelected(AdapterView<?> parent, V
if (position == 0) {
title.clear();
news_id.clear();
date.clear();
description.clear();
img_url.clear();
source_url.clear();
category_to_fetch = "analysis";
getO(category_to_fetch);
} else if (position == 1) {
title.clear();
news_id.clear();
date.clear();
description.clear();
img_url.clear();
source_url.clear();
category_to_fetch = "blockchain";
getO(category_to_fetch);
} else if (position == 2) {
title.clear();
news_id.clear();
date.clear();
description.clear();
img_url.clear();
source_url.clear();
category_to_fetch = "exchanges";
getO(category_to_fetch);
} else if (position == 3) {
title.clear();
news_id.clear();
date.clear();
description.clear();
img_url.clear();
source_url.clear();
category_to_fetch = "general";
getO(category_to_fetch);
} else if (position == 4) {
title.clear();
news_id.clear();
date.clear();
description.clear();
img_url.clear();
source_url.clear();
category_to_fetch = "government";
getO(category_to_fetch);
} else if (position == 5) {
title.clear();
news_id.clear();
date.clear();
description.clear();
img_url.clear();
source_url.clear();
category_to_fetch = "ico";
getO(category_to_fetch);
} else if (position == 6) {
title.clear();
news_id.clear();
date.clear();
description.clear();
img_url.clear();
source_url.clear();
category_to_fetch = "mining";
getO(category_to_fetch);
}
}
StringRequest stringRequest = new StringRequest(
Request.Method.GET,
Utils.CATEGORY, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
Log.e("RESPONSE", response);
JSONObject jsonObject = new JSONObject(response);
Log.e("OBJECT", jsonObject.toString());
LOGCAT
这是STRING响应
E / RESPONSE:{“分析”:[// RESPONSE
将其转换为JSON对象后,它会显示下面的数据 E / OBJECT:{“ exchanges”:[//响应
当我从旋转数据中选择分析类别时
当我从spinner数据中选择分析类别是ICO
当我从旋转数据中选择分析类别时
其他
即使我有数据也没有加载数据
答案 0 :(得分:0)
JSON属性未排序。如果它们在解析前后突然以不同的顺序显示,就不会打扰您。
答案 1 :(得分:0)
如果您使用改造,请使用WITH DataSource AS
(
SELECT col1
,col2
,0 as level
,ROW_NUMBER() OVER(ORDER BY Col1, col2) AS [groupID]
,0 as anchorMatched
,col1 as startValue
FROM tbl_test
WHERE col1 IN (SELECT MIN(col1) FROM tbl_test)
UNION ALL
SELECT A.col1
,A.col2
,level + 1
,B.[groupID]
,anchorMatched + CASE WHEN A.col1 = B.col2 AND A.col2 = B.startValue THEN 1 ELSE 0 END
,b.startValue
FROM tbl_test A
INNER JOIN DataSource B
ON A.col1 = B.col2
WHERE (anchorMatched = 0 AND A.col1 <> B.startValue)
)
SELECT *
FROM DataSource
WHERE groupID = 1;
这个拦截器来记录请求和响应信息:
添加gradle:
实现'com.squareup.okhttp3:logging-interceptor:3.6.0'
并添加HttpLogginInterceptor
.addInterceptor(interceptor)
如果要打印响应,请使用GSON转换器:
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient client = new OkHttpClient.Builder()
.readTimeout(60, TimeUnit.SECONDS)
.connectTimeout(60, TimeUnit.SECONDS)
.writeTimeout(60, TimeUnit.SECONDS)
.addInterceptor(interceptor)
.cookieJar(new JavaNetCookieJar(cookieHandler))
.build();