我想为 Json 表单 URL 创建一个列表框..
我从 URL 获取 Json 数据。我已经解析了 JSON 数据.. 我的 JSON 数据包含产品基本流程,但我通过 this way 解析了 JSON 数据.
就像我遵循了许多教程一样..但是我的JSON数据可能会产生不恒定的产品信息,例如我已经解析了有关网站的数据..现在我想解析电影或产品的数据但是每次我需要时更改我想要的数据,就像自动更改一样,我已经在java上完成了这个应用程序,用于解析JSON,我使用了Hashmap..但现在在Windows中,我得到了get,set,但它只适用于一种产品..
还有一件事..在Android中我做了一个 ListView ,它会像这样..
所以我想显示包括数据的图像..我已经在 Android 上完成了此操作,但我想在 Windows 中构建它..
因为我想要一个列表框..像图像一样,所以当我单击任何项目表单列表框..它应该显示并且再次它应该有一个列表或表格.. 在 Android 中,我使用 Listview 到 singleitemview 来完成此操作,在该单项 View 中我添加了表格布局..
我陷入了这些情况..
在android中,对于一个类文件,我可以使用许多xml文件..但这里Xaml是主要的,它只有一个类文件..
当我在android中显示数据时,它是一个异步任务..所以现在它是关于标志,接下来是关于其他一些..我的意思是如果它 关于产品,第一次是针对移动设备,然后是针对 PC..
但是如果有告诉我任何方法的话,在 Windows 中这是不可能的
为了在 Android 中解析 JSON,我使用了 JSON 数组和带有 Hashmap 的 JSON 对象。 但在 Windows 中我发现只有 GET,set..
有没有办法像这样构建?我是 Windows Phone 新手..
这是我的 Json 数据。
{
"returnCode": "success",
"SPData": {
"result": [
{
"sdetails": [
{
"loffers": [
{
"id": "wKugoi00AOWi",
"price": "129.99",
"seller": "Google"
}
],
"O_count": 1,
"name": "google.com",
"r_count": 1,
"sku": "68190",
"url": "http://www.google.com"
},
{
"loffers": [
{
"id": "wAOWi",
"price": "129.99",
"seller": "Yahoo"
},
{
"id": "wKuAOWi",
"price": "130.99",
"seller": "Yahoo"
},
{
"id": "wKuWi",
"price": "123.99",
"seller": "Yahoo"
}
],
"offers_count": 3,
"name": "yahoo.com",
"r_count": 1,
"sku": "68190",
"url": "http://www.yahoo.com"
},
{
"loffers": [
{
"id": "7e8Wk",
"price": "99.99",
"seller": "amazon.com"
},
{
"id": "4XUaGAi",
"price": "129.99",
"seller": "amazon.com"
}
],
"offers_count": 2,
"name": "amazon.com",
"recentoffers_count": 1,
"sku": "7829033",
"url": "http://www.amazon.com"
}
],
"model": "AAA",
"weight": "1258.64",
"price_currency": "USD",
"gtins": [
"008411"
],
"mpn": "AAAAA",
"amam3_help": "To view additional merchants for this product, please upgrade your plan.",
"cat_id": "20780",
"height": "40.64",
"description": "Immersive action and endless unready to discover a... (visit site URLs for full description)",
"name": "xyz",
"features": {
"Wi-Fi Ready": "No",
"BD Live": "Yes",
"Coaxial Digital Audio Outputs": "1 [Connections that deliver audio signals to compatible A/V components in digital form. ]",
"Audio Outputs": "1 [Jacks that send audio signals to another A/V component. ]"
},
"length": "198.12",
"created_at": 1364157755,
"geo": [
"usa"
],
"width": "358.14",
"upc": "027242858411",
"ean": "0027242858411",
"category": "Blu-ray Players",
"price": "139.99",
"updated_at": 1390272838,
"manufacturer": "Sony",
"images_total": 1,
"images": [
"http://cpcstrategy.com/wp-content/uploads/2013/06/Google-logo-retargeting.jpg"
],
"brand": "Google",
"aam3_id": "4FyI",
"offers_total": 404
}
],
"total_results_count": 3,
"results_count": 3,
"code": "OK",
"offset": 0
}
}
所以如果我按照 Get 并设置功能总是可能不一样..所以在那里我会得到错误.. 在android中我通过这种方式解析..
JSONObject json_data = JSONfunctions.getJSONfromURL(url);
JSONObject json_query = json_data.getJSONObject("query");
JSONArray json_result = json_query.getJSONArray("result");
for (int i = 0; i < json_results.length(); i++) {
HashMap<String, String> map = new HashMap<String, String>();
JSONObject c = json_result.getJSONObject(i);
.
.
JSONArray flag = c.getJSONArray("flag");
for(int s=0;s<flag.length();s++)
{
System.out.println("URL"+flag.getString(s));
map.put("flag", flag.getString(s));
}
.
.
JSONArray json_result_site =c.getJSONArray("site");
for (int j = 0; j < c.length(); j++) {
if (j < json_result_site.length()) {
JSONObject s= json_result_site.getJSONObject(j);
map.put("url", s.optString("url"));
JSONArray json_latest = s.getJSONArray("latest");
for (int k = 0; k < json_latest.length(); k++) {
JSONObject e = json_latest.getJSONObject(k);
map.put("id", e.optString("id"));
map.put("date", e.optString("date"));
}
}
}
}
arraylist.add(map);
}
}
有没有办法在C#中加载数据.. 就像上面一样..
最佳答案
Windows Phone 使您能够通过使用 DataBining 轻松完成您所要求的操作,您所要做的就是将数据源与 XAML 控件绑定(bind),然后格式化您的 XAML 控件模板。
您在 android 中使用 ListView ,但在 windows Phone 中您可以LongListSelector 控制
要了解有关数据绑定(bind)和LongListSelector的更多信息,请参阅以下文章。
Data Binding to controls on Windows Phone
Windows Phone 8 XAML LongListSelector
Implementing the Model-View-ViewModel pattern in a Windows Phone app
关于c# - 如何在 Windows Phone 8 的单项 View 中创建列表框 View ?使用来自 url 的异步 JSON,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21257888/