Android OnEditorActionListener与imeOptions actionNext不工作
这是我的密码:Android OnEditorActionListener与imeOptions actionNext不工作,android,imeoptions,Android,Imeoptions,这是我的密码: <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"> <andro
<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>
不幸的是,当我按下键盘上的“下一步”按钮时,什么都没有发生。光标不会跳到下一个字段。
我看不出我遗漏了什么使用android:inputType=“text”为您的
文本输入文本
尝试调用view.requestFocus()代码>在您的操作中
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
Log.d(TAG,"handled: "+handled);
view.requestFocus() ; //add focus to next view object
return true; //return true
}
Log.d(TAG,"handled: "+handled);
return false; //add return
}
});
根据文件
下一步行动
输入法掩码动作位:动作键执行“下一步”操作,
将用户带到下一个接受文本的字段
这意味着它将关注下一个可聚焦的对象,如edittext或自动完成文本视图。因此,如果没有其他对象可以获得焦点,它将不会移动焦点。Hi@rafsanahmad007。我确实为我的特定操作设置了handled=true,然后该操作由方法返回。Hi@androidnoobdev,对象是一个TextInputLayout
,与上面的一样。所以我认为它应该能够获得焦点。@DeKekem然后添加这个属性-android:focusable=“true”android:focusableInTouchMode=“true”并立即检查;这是一个巨大的错误:如果这个字段隐藏在软键盘后面,IME\u ACTION\u NEXT不会导致跳转到下一个字段。我今天给安卓研发部发了一份bug报告。
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
Log.d(TAG,"handled: "+handled);
view.requestFocus() ; //add focus to next view object
return true; //return true
}
Log.d(TAG,"handled: "+handled);
return false; //add return
}
});