Android 监听软键盘按键与改变软键盘右下角按键样式

来源:互联网 发布:淘宝买家秀对比 编辑:程序博客网 时间:2024/04/28 22:15

android:singleline=”true”
android:imeoptions=”actionSearch”

一定要加singleline=”true”!!!

actionNone : 回车键,按下后光标到下一行
actionGo : Go,
actionSearch : 放大镜
actionSend : Send
actionNext : Next
actionDone : Done,确定/完成,隐藏软键盘,即使不是最后一个文本输入框

xml

            <EditText                android:imeOptions="actionSend"                android:id="@+id/et_input_message"                android:layout_width="0dp"                android:layout_height="match_parent"                android:layout_marginRight="15dp"                android:background="#ffffff"                android:layout_weight="1"                android:singleLine="true"                />

java

  et_input_message.setOnEditorActionListener(new EditText.OnEditorActionListener(){            @Override            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {                LogUtil.d("zza",actionId+"==");                switch (actionId) {                    case EditorInfo.IME_ACTION_NONE:                        Toast.makeText(getApplicationContext(), "点击NONE", Toast.LENGTH_SHORT).show();                        break;                    case EditorInfo.IME_ACTION_GO:                        Toast.makeText(getApplicationContext(), "点击GO", Toast.LENGTH_SHORT).show();                        break;                    case EditorInfo.IME_ACTION_SEARCH:                        Toast.makeText(getApplicationContext(), "点击SEARCH", Toast.LENGTH_SHORT).show();                        break;                    case EditorInfo.IME_ACTION_SEND:                        Toast.makeText(getApplicationContext(), "点击SEND", Toast.LENGTH_SHORT).show();                        break;                    case EditorInfo.IME_ACTION_NEXT:                        Toast.makeText(getApplicationContext(), "点击NEXT", Toast.LENGTH_SHORT).show();                        break;                    default:                        break;                }                return false;            }        });
0 1
原创粉丝点击