I have a MainActivity class with an Add Element button and a list and AddItemActivity class with a text box and a Save button. The user must click "Add Item", go to the AddItemActivity screen, enter the item, click "Save", and then return to the updated MainActivity screen.
(BTW, I am using MonoDroid, but I do not think it is necessary for a specific problem with MonoDroid).
My element "Add element" click (by main activity):
private void addItemButton_Click(object sender, EventArgs e)
{
var intent = new Intent();
intent.SetClassName(this, "monoApp.AddItemClassName");
StartActivityForResult(intent, 0);
}
My Save event click (when adding activity to an element):
private void saveButton_Click(object sender, EventArgs e)
{
var itemname = FindViewById<EditText>(Resource.id.itemName);
_repo.SaveItem(new Item() {Name = itemname.Text.ToString()});
Toast.MakeText(this, "You saved: " + itemname.Text, ToastLength.Short).Show();
var intent = new Intent();
SetResult(Result.Ok, intent);
Finish();
}
And again in the main activity:
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
base.OnActivityResult(requestCode, resultCode, data);
RefreshTheList();
}
, . " ", , . , , - . , , .
, , TwitVid: http://www.twitvid.com/W7XZC
, , " ", ?