我正在测试TextView
小部件,并希望使用editorActionListener
以编程方式调用已注册的textView.setOnEditorActionListener(...)
集。解雇此事件的正确方法是什么?
答案 0 :(得分:0)
试试这个......可能会有所帮助..
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;
}
});