2014-10-10 44 views

回答

1

1.「setOnFocusChangeListener」(繼承自android.view.View)用於整個視圖。
2.「setOnQueryTextFocusChangeListener」僅用於AutoCompleteTextView。

見搜索查看的代碼:

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); 
      } 
     } 
    }); 
相關問題