Meggy Peter

Meggy Peter

  • NA
  • 32
  • 3.2k

Not adding item in list view

Dec 5 2022 8:22 PM

Listview not adding value from second activity.

  1. I have ListView and Two Button at bottom in my First Activity. While I click on button it goes into Second activity 
  2. In Second activity I created form where I am trying to add details which goes into First activity listview But it not adding value into listview

                       if (edtName.Text != "" && edtDescription.Text != "" && edtDate.Text != "")
                    {
                        Intent intent = new Intent();
                        string Name = edtName.Text;
                        string Description = edtDescription.Text;
                        DateTime DateDeploy = DateTime.Parse(edtDate.Text);

                        intent.PutExtra("Name", Name.ToString());
                        intent.PutExtra("Descritption", Description.ToString());
                        intent.PutExtra("Date", DateDeploy.ToString());
                        intent = new Intent(this, typeof(FirstActivity)); 
                        //StartActivityForResult(intent, 0);
                        SetResult(Result.Ok,intent);
                        //StartActivity(intent);
                        Finish();
                    }

For this Second activity I added intent.putExtra for adding value from First activity. And In First Activity I added    protected override void OnActivityResult(int requestCode, Result resultCode, Intent data){

                     string name, desc, datecreated;

                    name = data.GetStringExtra("Name");
                    desc = data.GetStringExtra("Descritption");
                    datecreated = data.GetStringExtra("Date");

                   //Not Working Here

 

     }

Please, help me to how do i add item from second activity to first activity ListView


Answers (1)