与Windows开发不同,这个控件的事件比较难找,费了半天劲才知道应该用哪个事件。核心代码如下:
public class MainActivity : Activity { protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView (Resource.Layout.Main); var searchView1 = FindViewById<SearchView>(Resource.Id.searchView1); searchView1.SubmitButtonEnabled = true; searchView1.QueryTextSubmit += SearchView1_QueryTextSubmit; } private void SearchView1_QueryTextSubmit(object sender, SearchView.QueryTextSubmitEventArgs e) { var text = e.Query; } }