0
我有一個TextView
小工具,我正在測試,並且想要以編程方式調用使用textView.setOnEditorActionListener(...)
設置的已註冊editorActionListener
。什麼是解決這個事件的正確方法?以編程方式調用editorActionListener
我有一個TextView
小工具,我正在測試,並且想要以編程方式調用使用textView.setOnEditorActionListener(...)
設置的已註冊editorActionListener
。什麼是解決這個事件的正確方法?以編程方式調用editorActionListener
嘗試this..it可以幫助全..
TextView textview=(TextView)findViewById(R.id.searchText);//searchText is the id in XML layout
textview.setImeOptions(EditorInfo.IME_ACTION_SEARCH);// here it using for search operation..it depends upon your process
textview.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEARCH)
{
//peform operation.. if search key is pressed in keypad, it comes inside the condition..
return true;
}
return false;
}
});