Android OnEditorActionListener() actionId give 0 when I click Done key

拜拜、爱过 提交于 2019-12-03 06:33:42

Try this for adding Listener :

    msg_title_text.setOnEditorActionListener(new DoneOnEditorActionListener());

Created a class :

    class DoneOnEditorActionListener implements OnEditorActionListener {
    @Override
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
        if (actionId == EditorInfo.IME_ACTION_DONE) {
            Log.v("*****************************", "Clicke da machan");
            // Do your Stuffs
            return true;    
        }
        return false;
    }
}

if you wanna got the actionid try this way:

in my project i change the edittext's properties like that

input type  -----  text
ime options -----  actionDone

and in java file:

  etSearch = (EditText) findViewById(R.id.etSearch);
  etSearch.setOnEditorActionListener(mEditorActionListener);
private OnEditorActionListener mEditorActionListener = new OnEditorActionListener() {

    @Override
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
        // TODO Auto-generated method stub
        if (actionId == EditorInfo.IME_ACTION_DONE) {
                       //do something
        }
        return false;
    }
};

in this way could got the actionid = 6;

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!