private void btn_save_Click(object sender, EventArgs e) { // If the length of the text is more then 0.. do this.. if (txt_Name_.Text.Length > 0) { // Set the new PlayerName to the text in the textfield Hangman_Game.PlyerName = txt_Name_.Text.ToString(); // Give them a score of 0 to begin with Hangman_Game.score = 0; var cc = new MyConnection(); // Insert the Players name and score into the database cc.InsertNewPlayer(Hangman_Game.PlyerName, Hangman_Game.score); // And update the list List_Names = cc.ViewAll(); var da = new Resources.MyAdpater(this, List_Names); // And display the updated list on the spinner Name_Score_Spinner.Adapter = da; } // Display a message if there is an empty textfield else { Toast.MakeText(this, "Please Fill Name", ToastLength.Short).Show(); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.NewPlyr); MyConnection myConnectionClass = new MyConnection(); List_Names = myConnectionClass.ViewAll(); Name_Score_Spinner = FindViewById <Spinner>(Resource.Id.Spinnner_select); Hangman_3.Resources.MyAdpater da = new Resources.MyAdpater(this, List_Names); Name_Score_Spinner.Adapter = da; Name_Score_Spinner.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(spinner_ItemSelected); txt_Name_ = FindViewById <TextView>(Resource.Id.txt_Name); Button btn_Play_Game = FindViewById <Button>(Resource.Id.btn_Play_Game); btn_Play_Game.Click += btn_Play_Game_Click; Button btn_save = FindViewById <Button>(Resource.Id.btn_save); btn_save.Click += btn_save_Click; Button btn_Home_Page = FindViewById <Button>(Resource.Id.btn_Home_Page); btn_Home_Page.Click += btn_Home_Page_Click; }
private void btn_Delete_Click(object sender, EventArgs e) { var cc = new MyConnection(); cc.DeletePlayer(Hangman_Game.Id); List_All = cc.ViewAll(); var da = new Resources.MyAdpater(this, List_All); spinner_select.Adapter = da; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Del_Rec_Layout); MyConnection myConnectionClass = new MyConnection(); List_All = myConnectionClass.ViewAll(); btn_Home_Page = FindViewById <Button>(Resource.Id.btn_Home_Page); btn_Home_Page.Click += btn_Home_Page_Click; spinner_select = FindViewById <Spinner>(Resource.Id.spinner_select); Hangman_3.Resources.MyAdpater da = new Resources.MyAdpater(this, List_All); spinner_select.Adapter = da; spinner_select.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(spinner_select_ItemSelected); btn_Delete = FindViewById <Button>(Resource.Id.btn_Delete); btn_Delete.Click += btn_Delete_Click; btn_Delete.Enabled = false; }