私はXamarin C#でAndroidアプリを書いています。JSON(Xamarin C#)からの情報ダウンロード
JSONの情報を解析してフィールドに表示します。
私はこのコードを使用します
string url2 = "http://papajohn.pp.ua/?mkapi=getProductsByCat&cat_id=74";
JsonValue json = await FetchAsync(url2);
private async Task<JsonValue> FetchAsync(string url)
{
// Create an HTTP web request using the URL:
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(new Uri(url));
request.ContentType = "application/json";
request.Method = "GET";
// Send the request to the server and wait for the response:
using (WebResponse response = await request.GetResponseAsync())
{
// Get a stream representation of the HTTP web response:
using (Stream stream = response.GetResponseStream())
{
// Use this stream to build a JSON document object:
JsonValue jsonDoc = await Task.Run(() => JsonObject.Load(stream));
//dynamic data = JObject.Parse(jsonDoc[15].ToString);
Console.Out.WriteLine("Response: {0}", jsonDoc.ToString());
// Return the JSON document:
return jsonDoc;
}
}
}
をしかし、私は一つの問題があります。アクティビティを開くと2〜3秒間フリーズし、すべての情報がフィールドに表示されます。
データをスムーズにダウンロードできますか?最初のフィールド、次に秒など
もし私ができれば、どうですか?
あなたがボレーを使用することができますが含まれるように、例えばhttp://www.androidhive.info/2014/09/android-json-parsing-using-volley/ –
これはJava用です。 私はC#@AlLelopath –
を使用しています。あなたは 'FetchAsync'をどのように呼び出すかを示し、あなたの値を設定します。 –