private void btn_save_Click(object sender, EventArgs e) { if (txtEd_Name.Text.Length > 0) { // Set the new PlayerName to the text in the textfield My_Hangman_Game_Activity.PlayerName = txtEd_Name.Text.ToString(); // Give them a score of 0 to begin with My_Hangman_Game_Activity.score = 0; var cc = new My_Sqlite_Connection(); // Insert the Players name and score into the database cc.InsertNewPlayer(My_Hangman_Game_Activity.PlayerName, My_Hangman_Game_Activity.score); // And update the list All_Records = cc.ViewAll(); var da = new Resources.My_Adapter_Spinner(this, All_Records); // And display the updated list on the spinner Name_Spinner.Adapter = da; Toast.MakeText(this, "Profile Name Saved ", ToastLength.Short).Show(); StartActivity(typeof(My_Hangman_Game_Activity)); } // Display a message if there is an empty textfield else { Toast.MakeText(this, "Please enter your name", ToastLength.Short).Show(); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.My_All_Score_Layout); btn_play_again = FindViewById <Button>(Resource.Id.btn_play_again); btn_play_again.Click += btn_play_again_Click; MyCon = new My_Sqlite_Connection(); List_Max = MyCon.ViewAll(); ListView List_View_All = FindViewById <ListView>(Resource.Id.List_View_All); List_View_All.Adapter = new My_Adapter_Spinner(this, List_Max); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); SetContentView(Resource.Layout.activity_main); My_Sqlite_Connection Con = new My_Sqlite_Connection(); All_Records = Con.ViewAll(); Name_Spinner = FindViewById <Spinner>(Resource.Id.Name_Spinner); Hangman_Joban.Resources.My_Adapter_Spinner da = new Resources.My_Adapter_Spinner(this, All_Records); Name_Spinner.Adapter = da; Name_Spinner.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(Name_Spinner_ItemSelected); txtEd_Name = FindViewById <TextView>(Resource.Id.txtEd_Name); Button btn_save = FindViewById <Button>(Resource.Id.btn_save); btn_save.Click += btn_save_Click; }