EditText添加android:imeOptions="actionSearch"弹出的键盘中带有搜索按钮

首先在布局文件中的EditText添加android:imeOptions="actionSearch"   android:inputType="text";

phoneEd.setOnEditorActionListener(new TextView.OnEditorActionListener(){ 

    @Override  

public boolean onEditorAction(TextView arg0, int arg1, KeyEvent arg2) {  

// TODO Auto-generated method stub  

if(arg1 == EditorInfo.IME_ACTION_SEARCH)  

                {  

                    Toast.makeText(AddMemberActivity.this,"呵呵",Toast.LENGTH_SHORT).show();  

// search pressed and perform your functionality.  

               }  

return false;  

           }  

        });  

 

posted on 2018-01-04 13:51  1060810756  阅读(5668)  评论(0编辑  收藏  举报