这里是我的代码: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