android 手动回收对象,Android Studio Studio回收列表中的JSON对象
我想在recyclerview中顯示一些JSON對(duì)象,并且希望它們在日期之后排序,我該如何實(shí)現(xiàn)?下面是下載從JSON URL的數(shù)據(jù)的方法:Android Studio Studio回收列表中的JSON對(duì)象
public void downloadFromSkistar()
{
try
{
URL url = new URL("XXXXX");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setReadTimeout(10000 /* milliseconds */);
conn.setConnectTimeout(15000 /* milliseconds */);
conn.setRequestMethod("GET");
// Starts the query
conn.connect();
int response = conn.getResponseCode();
Log.i("AndroidExample", "Response: " + response);
if (response == 200)
{
String json = getJson(conn.getInputStream());
JSONObject jsonObject = new JSONObject(json);
JSONArray jsonArray = jsonObject.getJSONArray("rideStatistics");
int reponame = 0;
for (int i = 0; i < jsonArray.length(); i++)
{
JSONObject skiRun = jsonArray.getJSONObject(i);
reponame += skiRun.getInt("height");
}
final int height = reponame;
final int count = jsonArray.length();
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
dropHeight.set("" + height);
rideCount.set("" + count);
}
});
}
}
catch (Exception e)
{
Log.i("AndroidExample", "Error");
}
finally
{
}
}
我不知道我是否能提供足夠的信息,因?yàn)槲液苄碌倪@一點(diǎn),基本上是我想要的是顯示JSON對(duì)象內(nèi)我的回收查看列表與最新日期第一等對(duì)象
+0
您需要?jiǎng)?chuàng)建循環(huán)視圖自定義適配器接受JSON對(duì)象和顯示 –
+0
可能重復(fù):http://stackoverflow.com/questions/32562107/how -to-排序的數(shù)據(jù)功能于recyclerview –
總結(jié)
以上是生活随笔為你收集整理的android 手动回收对象,Android Studio Studio回收列表中的JSON对象的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: VS2012番茄助手安装破解教程
- 下一篇: android sina oauth2.