Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Add event by clicking button design of axml in monodroid?
- public class Activity1 : Activity
- {
- string dbPath = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "tdsl_validation.sqlite");
- private Button login_button;
- private EditText user;
- private EditText passs;
- protected override void OnCreate(Bundle bundle)
- {
- var ss=dbPath;
- base.OnCreate(bundle);
- user = (EditText)FindViewById(Resource.Id.editText1);
- passs = (EditText)FindViewById(Resource.Id.editText3);
- login_button = (Button)FindViewById(Resource.Id.button1);
- login_button.Click += new EventHandler(button1_Click);
- SetContentView(Resource.Layout.Main);
- }
- private bool validate_user(string username, string password)
- {
- bool i;
- i = true;
- string str;
- DataTable dt = new DataTable();
- string dbPath1 = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "tdsl_validation.sqlite");
- SqliteConnection con = new SqliteConnection("Data Source="+ dbPath1);
- str = "select pass from user_detail where user_name='" + username + "' and pass='" + password + "'";
- SqliteCommand cmd = new SqliteCommand(str, con);
- SqliteDataAdapter da = new SqliteDataAdapter(cmd);
- da.Fill(dt);
- if (dt != null)
- {
- if (dt.Rows.Count > 0)
- {
- i = true;
- }
- else
- {
- i = false;
- }
- }
- else
- {
- i = false;
- }
- return i;
- }
- void button1_Click(object sender, EventArgs e)
- {
- bool i;
- user = (EditText)FindViewById(Resource.Id.editText1);
- passs = (EditText)FindViewById(Resource.Id.editText3);
- i = validate_user(user.Text, passs.Text);
- i = validate_user(user.Text, passs.Text);
- if (i == true)
- {
- }
- else
- {
- Toast.MakeText(this, "Invalid Username or Password", ToastLength.Short).Show();
- }
- // stuff here
- }
- }
- SetContentView(Resource.Layout.Main);
- Button button = FindViewById<Button>(Resource.Id.MyButton);
- button.Click += delegate {
- // handle the click event here
- };
- button.Click += ButtonClicked;
- private void ButtonClicked(object sender, EventArgs eventArgs)
- {
- // handle button click here
- }
Add Comment
Please, Sign In to add comment