protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); employeeDirectory = new EmployeeDirectoryClient(WorklightClient.CreateInstance(this)); SearchView search = FindViewById <SearchView> (Resource.Id.searchView1); TextView lblName = FindViewById <TextView> (Resource.Id.lblName); TextView lblEmail = FindViewById <TextView> (Resource.Id.lblEmail); TextView lblPhone = FindViewById <TextView> (Resource.Id.lblPhone); search.QueryTextSubmit += async(object sender, SearchView.QueryTextSubmitEventArgs e) => { Employee employeeRecord = await employeeDirectory.FindEmployee(search.Query); if (employeeRecord != null) { lblName.Text = employeeRecord.Name; lblEmail.Text = employeeRecord.Email; lblPhone.Text = employeeRecord.Phone; } else { lblName.Text = "No Record Found"; lblEmail.Text = ""; lblPhone.Text = ""; } }; }
public override void ViewDidLoad() { base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib. lblName.Text = ""; lblEmail.Text = ""; lblPhone.Text = ""; // // Create instance of MFP client // employeeDirectory = new EmployeeDirectoryClient(WorklightClient.CreateInstance()); tbxSearch.ShouldReturn += (textField) => { tbxSearch.ResignFirstResponder(); return(true); }; tbxSearch.Ended += async delegate(object sender, EventArgs e) { Employee employeeRecord = await employeeDirectory.FindEmployee(tbxSearch.Text); if (employeeRecord != null) { lblName.Text = employeeRecord.Name; lblEmail.Text = employeeRecord.Email; lblPhone.Text = employeeRecord.Phone; } else { lblName.Text = "No record found"; lblEmail.Text = ""; lblPhone.Text = ""; } }; }