Forum Xamarin.Android


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

c#- retrieving data from JSON to list view

I'm trying to get all events in LA from ticketMaster API I got the data from the json and placed it into a class object (Event). The problem is when I write the events list in the Console it apears in the Console but nothing shows in the listview , I tried to add the events using an addtional method and calling it after CreateEvents() but nothing changed. the json structure: json structure

The question is different than the one I posted yesterday since the problem here is when retriving the data it dosent apear in the list view

below is the subset of the code

public class Events { dynamic name1; dynamic type1; dynamic url1; public Events() { } public string name { get; set; } public string type { get; set; } public string url { get; set; } }

and the method I'm using to retrive the data

` private static readonly HttpClient _client = new HttpClient();

public async void CreateEvents()
    Events temp;

    Task<HttpResponseMessage> task = _client.GetAsync(url);
    HttpResponseMessage response = await task;
    string responseString = await response.Content.ReadAsStringAsync();
    dynamic obj = JsonConvert.DeserializeObject<dynamic>(responseString);

    Console.WriteLine("***** Events *****");

    for (int i = 0; i <; i = i + 1){
        temp = new Events(); =[i].name;
        temp.url =[i].url;
    Console.WriteLine("***** Events *****" + evs.Count);

    for (int i = 0; i < evs.Count; i = i + 1)
        Console.WriteLine("#" + i + "  " + evs[i].name.ToString());
        tableItems.Add(new TableItem() { Heading = evs[i].name.ToString(), SubHeading = "LA", ImageResourceId = });



  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    I think you should post more code.

    What is tableItems?

    How do you define your ListView?

  • JassimRahmaJassimRahma USMember ✭✭✭✭
    edited December 2017

    I have this code @AlessandroCaliaro

    var client = new HttpClient();
    client.BaseAddress = new Uri("" + txtSigninEmail.Text + "&password=" + txtSigninPassword.Text);
    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
    HttpResponseMessage response = await client.GetAsync("" + txtSigninEmail.Text + "&password=" + txtSigninPassword.Text);
    if (response.IsSuccessStatusCode)
        var data = await response.Content.ReadAsStringAsync();
        dynamic loginuserdata = JsonConvert.DeserializeObject(data);
        await DisplayAlert("TOTAL COUNT", Convert.ToString(loginuserdata.**Count**), "OK");

    I want to know how can I get the count of the returned data in order to give the right message when no user exist and proceed when user and password are correct?

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    I think you have to cast your object

    something like

Sign In or Register to comment.