how to add Go button in android SoftKeyBoard and its functionality?

前端 未结 4 752
渐次进展
渐次进展 2021-02-06 04:26

i want to put \"Go\" button in android appliation softkeyboard

for search and other related scenarios can any one guide me how to achieve this? with example.

any

4条回答
  •  盖世英雄少女心
    2021-02-06 05:21

    I used

    android:imeOptions="actionGo" 
    

    and to handle go action I ma using

    etSearch.setOnEditorActionListener(new TextView.OnEditorActionListener() {
                @Override
                public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                    if (actionId == EditorInfo.IME_ACTION_GO || actionId == EditorInfo.IME_ACTION_DONE) {
                        //your functionality 
    
                        // hide virtual keyboard
                        InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
                        imm.hideSoftInputFromWindow(etSearch.getWindowToken(), InputMethodManager.RESULT_UNCHANGED_SHOWN);
    
                        return true;
                    }
                    return false;
                }
            });
    

提交回复
热议问题