关于软键盘的下一步的操作
这个操作要使用textview或者edittext的 android:imeOptions属性来操作,这个属性包括
actionDone(完成),
actionNext(下一步),
actionGo(开始),
actionSearch(搜索),
actionNone(什么都没有),
actionPrevious(上一步),
actionSend(发送)
这几个子属性。但是要使这几个属性生效必须要加上
android:singleLine=”true”(目前这个属性已经备废弃掉了),谷歌建议使用android:maxLines=”1”代替。或者加上android:inputType=”text”这个属性,貌似这个属性只能是text才能生效。
设置完成后需要在java代码中监控软件盘右下角的点击事件,例如:
etPwd.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId== EditorInfo.IME_ACTION_DONE{//这里判断右下角的属性,要和你在xml文件中设置的一样。
.....//这里进行你的操作
}
return false;
}
});
下面这个是我写的一个edittext的xml文件
<EditText
***android:maxLines="1"
android:imeOptions="actionDone"***
android:id="@+id/et_pwd"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="2dp"
android:layout_toRightOf="@id/iv_pwd"
android:background="@color/white"
android:hint="@string/password"
android:inputType="textPassword"
android:maxLength="16"
android:textSize="16sp"/>
主要的代码就是假*的那两行。好了,就到这里了,祝你操作成功。