void populateFromDb(object sender, EventArgs e) { var records = new AnxityDatabase().GetAnxityRecordsAsync().Result; foreach (AnxityRecords anx in records) { } }
public void DoSmthNew(object sender, EventArgs e) { var formLocation = Activity.FindViewById <EditText>(Resource.Id.formLocation).Text; var formDate = Activity.FindViewById <EditText>(Resource.Id.formDate).Text; var formNote = Activity.FindViewById <EditText>(Resource.Id.formNote).Text; var record = new AnxityRecords(formLocation, formDate, 3, formNote, "art"); var db = new AnxityDatabase(); db.SaveAnxityRecordAsync(record); Android.App.AlertDialog cat = new Android.App.AlertDialog.Builder(Activity).Create(); cat.SetMessage("Location : " + formLocation + " || Date :" + formDate + " || Note : " + formNote); var trans = Activity.SupportFragmentManager.BeginTransaction(); trans.Replace(Resource.Id.fragmentLayout, new Journal(), "Main_Page"); trans.Commit(); cat.SetTitle("message title"); cat.SetButton("OK", delegate { }); cat.Show(); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { //TO-DO: Order Records By the Dates -> Create View for the records View view = inflater.Inflate(Resource.Layout.JournalFragment, container, false); LinearLayout textHold = view.FindViewById <LinearLayout>(Resource.Id.journalRecordsWrapper); List <AnxityRecords> records = new AnxityDatabase().GetAnxityRecordsAsync().Result; var c = records.GroupBy(p => p.date); foreach (var anx in c) { if (anx.Count() > 0) { LinearLayout externalWrapper = new LinearLayout(Context); LinearLayout.LayoutParams generalLayoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); externalWrapper.LayoutParameters = generalLayoutParams; externalWrapper.Orientation = Orientation.Vertical; RelativeLayout layout_4 = new RelativeLayout(Context); RelativeLayout.LayoutParams layout_4_params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); layout_4.LayoutParameters = layout_4_params; RelativeLayout Rlayout_left = new RelativeLayout(Context); RelativeLayout.LayoutParams RlayoutRule = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); Rlayout_left.LayoutParameters = RlayoutRule; RlayoutRule.AddRule(LayoutRules.AlignParentLeft); TextView textView = new TextView(Activity); textView.Text = "Date: " + anx.Key; textView.SetTypeface(Typeface.Serif, TypefaceStyle.Bold); textView.SetPadding(60, 50, 0, 50); Rlayout_left.AddView(textView); RelativeLayout Rlayout_right = new RelativeLayout(Context); RelativeLayout.LayoutParams RlayoutRule_2 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); RlayoutRule_2.AddRule(LayoutRules.AlignParentRight); Rlayout_right.LayoutParameters = RlayoutRule_2; TextView textView2 = new TextView(Activity); textView2.Text = "Tracked: " + anx.Count(); textView2.SetTypeface(Typeface.Serif, TypefaceStyle.Bold); textView2.SetPadding(0, 50, 70, 50); Rlayout_right.AddView(textView2); LinearLayout separatorLayout = new LinearLayout(Context); separatorLayout.SetBackgroundColor(Color.LightGray); LinearLayout.LayoutParams separatorParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, 7); separatorLayout.LayoutParameters = separatorParams; separatorLayout.SetPadding(0, 30, 0, 30); layout_4.AddView(Rlayout_right); layout_4.AddView(Rlayout_left); externalWrapper.AddView(layout_4); externalWrapper.AddView(separatorLayout); LinearLayout s1Layout = getRecordsLayout(anx); externalWrapper.AddView(s1Layout); textHold.AddView(externalWrapper); } } return(view); }