protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); List <Comment> listView_Comments = JsonConvert.DeserializeObject <List <Comment> >(Intent.GetStringExtra("Comments")); SetContentView(Resource.Layout.comment_layout); ListAdapter = new CommentAdapter(this, listView_Comments); button_addComment = FindViewById <Button>(Resource.Id.button_addComment); button_addComment.Click += Button_addComment_Click; }
private void Button_addComment_Click(object sender, EventArgs e) { Button commentButton = (Button)sender; int position = (int)commentButton.Tag; EditText AddCommentText = FindViewById <EditText>(Resource.Id.textInputEditText_addComment); MainActivity.postList[position].Comments.Add(new Comment { Name = "TestUser", CommentText = AddCommentText.Text, }); AddCommentText.Text = ""; ListAdapter = new CommentAdapter(this, MainActivity.postList[position].Comments); }