protected void AddNewPlot(object sender, EventArgs e, Activity currentActivity) { try { btn_addnewplot.Click -= (sndr, argus) => AddNewPlot(sndr, argus, currentActivity); AddEditPlotFragment obj = new AddEditPlotFragment(); Android.Support.V4.App.FragmentTransaction tx = FragmentManager.BeginTransaction(); tx.Replace(Resource.Id.m_main, obj, Constants.addeditplot); tx.Commit(); } catch (Exception ex) { currentActivity.RunOnUiThread(() => { Android.App.AlertDialog.Builder alertDiag = new Android.App.AlertDialog.Builder(currentActivity); alertDiag.SetTitle(Resource.String.DialogHeaderError); alertDiag.SetMessage(ex.Message); alertDiag.SetIcon(Resource.Drawable.alert); alertDiag.SetPositiveButton(Resource.String.DialogButtonOk, (senderAlert, args) => { //btn_addnewplot.Click += (sndr, argus) => AddNewPlot(sndr, argus, currentActivity); }); Dialog diag = alertDiag.Create(); diag.Show(); diag.SetCanceledOnTouchOutside(false); }); } }
private void ItemSearch_clicked(object sender, AdapterView.ItemClickEventArgs e, Activity currentActivity) { try { androidGridView.ItemClick -= (sndr, argus) => ItemSearch_clicked(sndr, argus, currentActivity); AddEditPlotFragment obj = new AddEditPlotFragment(); Bundle utilBundle = new Bundle(); utilBundle.PutString("siteparam", farmid); utilBundle.PutString("siteparam0", gridViewCodeString[e.Position]); obj.Arguments = utilBundle; Android.Support.V4.App.FragmentTransaction tx = FragmentManager.BeginTransaction(); tx.Replace(Resource.Id.m_main, obj, Constants.addeditplot); tx.Commit(); } catch (Exception ex) { currentActivity.RunOnUiThread(() => { Android.App.AlertDialog.Builder alertDiag = new Android.App.AlertDialog.Builder(currentActivity); alertDiag.SetTitle(Resource.String.DialogHeaderError); alertDiag.SetMessage(ex.Message); alertDiag.SetIcon(Resource.Drawable.alert); alertDiag.SetPositiveButton(Resource.String.DialogButtonOk, (senderAlert, args) => { androidGridView.ItemClick += (sndr, argus) => ItemSearch_clicked(sndr, argus, currentActivity); }); Dialog diag = alertDiag.Create(); diag.Show(); diag.SetCanceledOnTouchOutside(false); }); } }
public static Android.Support.V4.App.Fragment newInstance(Context context) { AddEditPlotFragment busrouteFragment = new AddEditPlotFragment(); return(busrouteFragment); }