android SearchView有两个方法:setonQueryTextFocuschangelistener和setonFocuschangelistener.它们可以互换吗?他们之间有什么区别?
解决方法
1.“setonFocuschangelistener”(从android.view.View继承)用于整个视图.
2.“setonQueryTextFocuschangelistener”仅适用于AutoCompleteTextView.
2.“setonQueryTextFocuschangelistener”仅适用于AutoCompleteTextView.
查看SearchView的代码:
public void setonQueryTextFocuschangelistener(OnFocuschangelistener listener) { mOnQueryTextFocuschangelistener = listener; } ****** mQueryTextView = (SearchAutoComplete) findViewById(R.id.search_src_text); ****** mQueryTextView.setonFocuschangelistener(new OnFocuschangelistener() { public void onFocusChange(View v,boolean hasFocus) { if (mOnQueryTextFocuschangelistener != null) { mOnQueryTextFocuschangelistener.onFocusChange(SearchView.this,hasFocus); } } });