【发布时间】:2014-07-20 10:47:08
【问题描述】:
我有一个连接到数据库并返回 JSONArray 的 AsyncTask。数据显示在 ListView 中。现在,如果我单击 ListItem,我将使用 JSONObject 中的数据开始一个新的 Intent
Intent it = new Intent(DisplaySearchResults.this, Display.class);
try
{
it.putExtra("ID", jArray.getJSONObject(position).getString("ID").toString());
it.putExtra("TITLE", jArray.getJSONObject(position).getString("TITLE").toString());
it.putExtra("STRING", jArray.getJSONObject(position).getDouble("STRING"));
it.putExtra("SOME TEXT", jArray.getJSONObject(position).getString("SOME TEXT").toString())
} catch (JSONException e)
{
e.printStackTrace();
}
startActivity(it);
现在可以用类似的东西来启动显示类
Display d = new Display(jsonArray);
【问题讨论】:
-
JSONArray 基本上是一个字符串,因此您可以将整个 JSON 对象作为额外的。
-
谢谢 - 至少这样更容易:)
标签: android class android-intent