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

前端 未结 2 1690
不思量自难忘°
不思量自难忘° 2021-02-06 00:51

I have created one keyboard.When user enter numbers , its entering particular EditText.But When User click on Done key, it didn\'t go to setOnEditorActionList

相关标签:
2条回答
  • 2021-02-06 01:34

    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;
        }
    }
    
    0 讨论(0)
  • 2021-02-06 01:53

    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;

    0 讨论(0)
提交回复
热议问题