0

I am using xamarin android to pull rest data from an api. I deserialise the data and display it in a list like so private void

ParseAndDisplay(JsonValue json)
        {
            var lstData = FindViewById<ListView>(Resource.Id.listView1);
            List<Team> list_teams = new List<Team>();
            RootObject objs = JsonConvert.DeserializeObject<RootObject>(json.ToString());
            foreach (var obj in objs.teams)
            {
                var id = obj._links.self.href;
                var indexOfLastBackSlash = id.LastIndexOf("/") + 1;
                id = id.Substring(indexOfLastBackSlash);

                Team team = new Team();
                team.name = obj.name;
                list_teams.Add(team);
                var slist = new List<string>();
                foreach (Team t in list_teams)
                {
                    string s = t.name;
                    slist.Add(s);
                }
                var data = new string[] { };
                data = slist.ToArray();
                lstData.Adapter = new ArrayAdapter(this, Resource.Layout.listViewTemplate, data);
                //lstTeams.Visibility = ViewStates.Visible;
                //ListView lstTeams = FindViewById<ListView>(Resource.Id.lstTeams);
                //ArrayAdapter<string> adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, Convert.ToInt32(list_teams));
                // ListAdapter = new ArrayAdapter
            }

I want to select a team from the list and display more detail on them and I will need the id for this. How can I select an item and carry these details across?

Cathy Regan
  • 251
  • 1
  • 2
  • 7
  • Or http://stackoverflow.com/questions/13633092/efficiently-passing-custom-object-data-between-android-activities-mono-android – SushiHangover Apr 27 '17 at 09:23
  • These do not answer my question. Mine is deserialised data that I need to pass on selection from a list view – Cathy Regan Apr 27 '17 at 09:35
  • As the linked examples show, either pass with your intent as extras, save to an application level variable, create a parcelable object, etc.... – SushiHangover Apr 27 '17 at 09:46

0 Answers0