這裏是我的代碼:OnEditorActionListener與imeOptions actionNext不工作
<android.support.design.widget.TextInputLayout
android:id="@+id/mylayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/some_layout">
<android.support.design.widget.TextInputEditText
android:id="@+id/myid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:hint="@string/some_hint"
android:imeOptions="actionNext"
android:inputType="time"
android:maxLength="@integer/max_input_length"
android:maxLines="1"
android:singleLine="true"
android:textSize="15sp"/>
</android.support.design.widget.TextInputLayout>
和Java代碼:
myField = (TextInputEditText) findViewById(R.id.myid);
myField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
boolean handled = false;
if (actionId == EditorInfo.IME_ACTION_NEXT) {
Log.d(TAG,"next");
//Do something
handled = true;
}
Log.d(TAG,"handled: "+handled);
return handled;
}
});`
不幸的是,當我按下鍵盤上的任何一個按鈕發生。光標不會跳轉到下一個字段。 我看不出有什麼我失蹤
嗨@androidnoobdev,對象是一個'TextInputLayout'就像上面的那個。所以我認爲它應該能夠得到關注。 – DeKekem
@DeKekem然後添加此屬性 - android:focusable =「true」 android:focusableInTouchMode =「true」並立即檢查。 – androidnoobdev