Forum Xamarin.Android

How can I send a renewable list of Objects through an intent to another activity?

I am trying as an exercise for learning to build a project that can handle and manage typed entries from the end user.
I created a custom numeric pad with a Send button. Every time the user clicks on a number or a combination of numbers and then he presses the Send button, the application should do two things. First send the two values (the pressed number combination and the actual time the Send button is pressed) to a web service for further management and second write those two values in a list of objects and send that list over to another activity where it can be shown as a listview to the user for reference.
My problem lies in the second part of the application.
The only way that I managed to make it work is by, either concatenating the two values in one string and send that string over to the other activity by an intent, or by serializing the object using Newtonsoft.Json.JsonConvert.SerializeObject() and sending the produced string over by an intent.
In this way my listview is "ugly". I want to make a custom adapter and show the list to the user in two columns, each containing one value(the time and the number).
The thing is that I cannot figure out how to deserialize the list in order to obtain the seperate values on the other activity and show them in a list.
This is the code for the Send Button:

static readonly List bibTimes = new List();

buttonSend.Click += (object sender, EventArgs e) =>
Participant part = new Participant();
DateTime ts = DateTime.Now;
part.PartBib = athleteBib.Text;
part.PartTime = ts.ToString();
string serialize = Newtonsoft.Json.JsonConvert.SerializeObject (part);
athleteBib.Text = null;
buttonSend.Enabled = false;


and the code for the intent:

public void ShowRecords()
var intent = new Intent(this, typeof(TimeRecordsActivity));
intent.PutStringArrayListExtra("bib_times", bibTimes);

The other activity that shows the list to the user is:

[Activity(Label = "TimeRecordsActivity")]
public class TimeRecordsActivity : ListActivity

    protected override void OnCreate(Bundle bundle)
        var bibTimes = Intent.Extras.GetStringArrayList("bib_times") ?? new string[0];
        this.ListAdapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, bibTimes);


Is there any way to deserialize the list and make it more presentable??

Sign In or Register to comment.