我正在嘗試構建登錄表單。這是我的密碼字段的xml:必須在鍵盤上按兩次鍵才能登錄
<android.support.design.widget.TextInputLayout
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
app:errorEnabled="true">
<android.support.design.widget.TextInputEditText
android:id="@+id/password_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/password"
android:inputType="textPassword"
android:imeOptions="actionGo"/>
</android.support.design.widget.TextInputLayout>
,並在那裏我聽着前進按鍵看起來像這樣的loginActivity:
@OnClick(R.id.password_input)
public void Start() {
EditText editText = (EditText) findViewById(R.id.password_input);
editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
boolean handled = false;
if (actionId == EditorInfo.IME_ACTION_GO) {
logIn();
handled = true;
}
return handled;
}
});
}
當我按密碼字段鍵盤彈出,然後我有按兩次轉入鍵以調用logIn()函數。可能是什麼原因,我該如何解決這個問題?
如果工作然後接受的答案。 –
仍然必須按兩次Enter鍵登錄。我需要登錄操作發生在單擊。 –
@Al Noman我必須讓它工作在一個單一的點擊,它已經發生,當我按Enter鍵兩次。 –