【发布时间】:2014-11-06 10:18:04
【问题描述】:
我正在使用包含消息和时间令牌的 pubnub 获取我的历史列表的应用程序。原始Json字符串如下:
[[{"message":"hdjcjcjjckckckckvkckckck","timetoken":14151866297757284},{"message":"ufjfjfjcjfjchfjdhwjroritkgjcj","timetoken":14151869212145693},{"message":"qMobile","timetoken":14152601234812083}],14151866297757284,14152601234812083]
使用以下方法后,我在 JSONObject c 中得到了以下 Json 字符串。
{"message":"hdjcjcjjckckckckvkckckck","timetoken":14151866297757284}
pubnub.history(channel, true, 100, new Callback() {
@Override
public void successCallback(String channel,
Object message) {
notifyUser("HISTORY : " + message);
Log.i("Received msg : ", message.toString()); //<==== receiving Messages here
try {
JSONArray jsonObj = new JSONArray(message.toString());
JSONArray jArray = new JSONArray(jsonObj.get(0).toString());
for (int i = 0; i < jArray.length(); i++) {
JSONObject c = jArray.getJSONObject(i);
String messageString=c.getString("message");
String timeString=c.getString("timetoken");
String abc = timeString;
}
}
现在我只想像这样在 ListView 中显示我的每个 Json 对象
消息:dsfdsvsfvdfvfdvdvgd
时间令牌:14132423414141
消息:dsfwfwefwedcsfsw
时间令牌:21431353153252
消息:dthfjtyhnfgvb
时间令牌:68624526246
提前致谢。
【问题讨论】:
-
然后实现ListAdapter并展示出来。
-
@pratt 感谢您的回复。你能为此提供一些代码sn-p吗?因为我没有为此获得 ListAdapter 技术。
-
为什么你不是 Gson api.. 试试看很简单
-
检查这个链接androidhive.info/2012/01/android-json-parsing-tutorial这可能对你有帮助..
-
@Chowdary102 我点击了您的链接,但它不允许我下载代码。如果您已经下载了副本,请在此处告诉我
标签: android json parsing android-listview pubnub