android在edittext中对回车键进行改变

来源:互联网 发布:音箱设计软件 编辑:程序博客网 时间:2024/06/03 14:08

使用imeoption属性


xml中的用法为

android:imeOptions="actionSend"

android:imeOptions="actionDone"


动态调用方法为

etx.setImeOptions(EditorInfo.IME_ACTION_DONE);

etx.setOnEditorActionListener(new OnEditorActionListener(){
@Override
public boolean onEditorAction(TextView arg0, int arg1,KeyEvent arg2) {
// TODO Auto-generated method stub
return false;
}
});

arg0为ext,arg1为action的id

修改回车键需要将edittext设置为单行模式

etx.setSingleLine(true);

0 0
原创粉丝点击