我有典型的登录屏幕。我能够使用 imeOptions 允许用户从一个字段“tab”到另一个字段,在最后一个字段(密码)上我有 actionDone - 它只是关闭软键盘。理想情况下,我喜欢自动点击“登录”。有什么内置的吗?
最佳答案
将 imeOptions 添加到您的密码 EditText 并以编程方式定义操作。
XML:
<EditText
android:id="@+id/passordEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Enter password"
android:inputType="textPassword"
android:imeOptions="actionSend"/>
java :
EditText passwordET= v.findViewById(R.id.passwordEditText);
passwordET.setOnEditorActionListener(new TextView.OnEditorActionListener() {
public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) {
boolean mHandled = false;
if (actionId == EditorInfo.IME_ACTION_SEND) {
onClick(yourLogInMethod);
mHandled = true;
}
return mHandled;
}
});
关于Android imeOptions 和自动按下登录按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5943081/