Guest User

Untitled

a guest
Sep 12th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 KB | None | 0 0
  1. Add event by clicking button design of axml in monodroid?
  2. public class Activity1 : Activity
  3. {
  4. string dbPath = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "tdsl_validation.sqlite");
  5.  
  6.  
  7.  
  8. private Button login_button;
  9. private EditText user;
  10. private EditText passs;
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17. protected override void OnCreate(Bundle bundle)
  18. {
  19. var ss=dbPath;
  20.  
  21. base.OnCreate(bundle);
  22. user = (EditText)FindViewById(Resource.Id.editText1);
  23. passs = (EditText)FindViewById(Resource.Id.editText3);
  24. login_button = (Button)FindViewById(Resource.Id.button1);
  25. login_button.Click += new EventHandler(button1_Click);
  26. SetContentView(Resource.Layout.Main);
  27.  
  28.  
  29. }
  30.  
  31.  
  32. private bool validate_user(string username, string password)
  33. {
  34. bool i;
  35. i = true;
  36. string str;
  37.  
  38. DataTable dt = new DataTable();
  39. string dbPath1 = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "tdsl_validation.sqlite");
  40.  
  41. SqliteConnection con = new SqliteConnection("Data Source="+ dbPath1);
  42. str = "select pass from user_detail where user_name='" + username + "' and pass='" + password + "'";
  43. SqliteCommand cmd = new SqliteCommand(str, con);
  44. SqliteDataAdapter da = new SqliteDataAdapter(cmd);
  45. da.Fill(dt);
  46.  
  47.  
  48. if (dt != null)
  49. {
  50. if (dt.Rows.Count > 0)
  51. {
  52. i = true;
  53.  
  54. }
  55. else
  56. {
  57. i = false;
  58. }
  59.  
  60. }
  61. else
  62. {
  63. i = false;
  64. }
  65.  
  66. return i;
  67.  
  68. }
  69.  
  70.  
  71.  
  72.  
  73.  
  74. void button1_Click(object sender, EventArgs e)
  75. {
  76. bool i;
  77. user = (EditText)FindViewById(Resource.Id.editText1);
  78. passs = (EditText)FindViewById(Resource.Id.editText3);
  79. i = validate_user(user.Text, passs.Text);
  80.  
  81. i = validate_user(user.Text, passs.Text);
  82. if (i == true)
  83. {
  84.  
  85. }
  86. else
  87. {
  88. Toast.MakeText(this, "Invalid Username or Password", ToastLength.Short).Show();
  89. }
  90.  
  91.  
  92.  
  93. // stuff here
  94. }
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103. }
  104.  
  105. SetContentView(Resource.Layout.Main);
  106.  
  107. Button button = FindViewById<Button>(Resource.Id.MyButton);
  108.  
  109. button.Click += delegate {
  110. // handle the click event here
  111. };
  112.  
  113. button.Click += ButtonClicked;
  114.  
  115. private void ButtonClicked(object sender, EventArgs eventArgs)
  116. {
  117. // handle button click here
  118. }
Add Comment
Please, Sign In to add comment