public override bool OnOptionsItemSelected(IMenuItem item) { switch (item.ItemId) { case Resource.Id.actionNew: if (POIListActivity.isDualMode) { var detailFragment = new POIDetailFragment(); FragmentTransaction ft = FragmentManager.BeginTransaction(); ft.Replace(Resource.Id.poiDetailLayout, detailFragment); ft.Commit(); } else { Intent intent = new Intent(activity, typeof(POIDetailActivity)); StartActivity(intent); } return(true); case Resource.Id.actionRefresh: DownloadPoisListAsync(); return(true); default: return(base.OnOptionsItemSelected(item)); } }
public override Dialog OnCreateDialog(Bundle savedInstanceState) { POIDetailFragment targetFragment = (POIDetailFragment)TargetFragment; string poiName = Arguments.GetString("name"); AlertDialog.Builder alertConfirm = new AlertDialog.Builder(this.Activity); alertConfirm.SetTitle("Confirm delete"); alertConfirm.SetCancelable(false); alertConfirm.SetPositiveButton("OK", (sender, e) => { targetFragment.DeletePOIAsync(); }); alertConfirm.SetNegativeButton("Cancel", delegate {}); alertConfirm.SetMessage(String.Format("Are you sure you want to delete {0}?", poiName)); return(alertConfirm.Create()); }
public override void OnListItemClick(ListView l, View v, int position, long id) { PointOfInterest poi = poiListData[position]; if (POIListActivity.isDualMode) { var detailFragment = new POIDetailFragment(); detailFragment.Arguments = new Bundle(); detailFragment.Arguments.PutString("poi", JsonConvert.SerializeObject(poi)); FragmentTransaction ft = FragmentManager.BeginTransaction(); ft.Replace(Resource.Id.poiDetailLayout, detailFragment); ft.Commit(); } else { Intent poiDetailIntent = new Intent(activity, typeof(POIDetailActivity)); poiDetailIntent.PutExtra("poi", JsonConvert.SerializeObject(poi)); StartActivity(poiDetailIntent); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.POIDetail); SetProgressBarIndeterminateVisibility(true); if (null == bundle) { var detailFragment = new POIDetailFragment(); detailFragment.Arguments = new Bundle(); if (Intent.HasExtra("poi")) { string poiJson = Intent.GetStringExtra("poi"); detailFragment.Arguments.PutString("poi", poiJson); } FragmentTransaction ft = FragmentManager.BeginTransaction(); ft.Add(Resource.Id.poiDetailLayout, detailFragment); ft.Commit(); } }