Exemple #1
0
        public bool OnActionItemClicked(ActionMode mode, IMenuItem item)
        {
            switch (item.ItemId)
            {
            case Resource.Id.menu_item_delete_crime:
                CrimeAdapter adapter  = (CrimeAdapter)ListAdapter;
                CrimeLab     crimelab = CrimeLab.GetInstance(Activity);
                for (int i = adapter.Count - 1; i >= 0; i--)
                {
                    if (ListView.IsItemChecked(i))
                    {
                        crimelab.DeleteCrime(adapter.GetItem(i));
                        adapter.Remove(adapter.GetItem(i));
                    }
                }
                mode.Finish();
                adapter.NotifyDataSetChanged();
                return(true);

            default:
                return(false);
            }
        }
Exemple #2
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            switch (item.ItemId)
            {
            case Resource.Id.menu_item_delete_crime:
                AlertDialog.Builder ad = new AlertDialog.Builder(Activity);
                ad.SetTitle(mCrime.Title);
                ad.SetMessage("Do you really want to delete this crime?");
                ad.SetCancelable(true);
                ad.SetPositiveButton("DELETE", delegate(object s, DialogClickEventArgs evt) {
                    CrimeLab crimelab = CrimeLab.GetInstance(Activity);
                    crimelab.DeleteCrime(mCrime);
                    // Using ParentActivity and NavUtils causes OnCreate to be called again
                    // in CrimeListFragment, causing the subtitle view to be reset
//						if (NavUtils.GetParentActivityName(Activity) != null) {
//							NavUtils.NavigateUpFromSameTask(Activity);
//						}
                    mCallBacks.RemoveCrimeFragment();
                    mCallBacks.OnCrimeUpdated();
                });
                ad.SetNegativeButton("Cancel", (s, evt) => {});
                ad.Show();
                return(true);

            case Android.Resource.Id.Home:
                // Using ParentActivity and NavUtils causes OnCreate to be called again
                // in CrimeListFragment, causing the subtitle view to be reset
//					if (NavUtils.GetParentActivityName(Activity) != null) {
//						NavUtils.NavigateUpFromSameTask(Activity);
//					}
                mCallBacks.RemoveCrimeFragment();
                return(true);

            default:
                return(base.OnOptionsItemSelected(item));
            }
        }