asp.net web api - How to show Json string data in list view for multiple columns in Xamarin.android using C#? -


i trying make android app using xamarin. new xamarin, facing issue i.e how display json string data in listview or in grid.

i using webapi fetch data database. webapi returns string is-

[{"questionid":2,"question1":"4,8,12 digit greatest?","answer":"12"}] 

method using in android application is-

 private string questionlist()         {              var url = httpwebrequest.create(string.format(@"url"));             url.contenttype = "application/json";             url.method = "get";             string tempdata = string.empty;             using (httpwebresponse response = url.getresponse() httpwebresponse)             {                 if (response.statuscode != httpstatuscode.ok)                     console.out.writeline("error", response.statuscode);                 using (streamreader reader = new streamreader(response.getresponsestream()))                 {                     var content = reader.readtoend();                       if (string.isnullorwhitespace(content))                     {                          console.out.writeline("response");                     }                     else {                         console.out.writeline("response", content);                         tempdata = content;                     }                 }             }             return tempdata;         } 

it returning json string on android device. want show data in list or in grid multiple columns.

first have use newtonsoft nuget package convert json string.

http://www.newtonsoft.com/json

you can use website json2csharp. provide json string in input , click in generate, create corresponding class you.

after can use xamarin documentation list view in android. https://developer.xamarin.com/guides/android/user_interface/working_with_listviews_and_adapters/part_2_-_populating_a_listview_with_data/

this tutoriel provide code examples create list view.

you have create custom adapter if want "customize" listview it's quite easy follow tutorial that.

to finish, give last link : https://www.youtube.com/watch?v=zzhlhrkvut0

this link of youtube channel tutorials android xamarin. when started using technologie, follow lot of videos.

if need more help, don't hesitate post more advanced code.

hope can you.


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -