我以前从未见过,只是想通了,所以我想写这个QnA。让我知道您是否认为这是重复的。
题:
我该如何做,以便当用户将注意力集中在屏幕上的最后一个 EditText
上时,它将为他们提供软键盘上的选项以按“下一步”,然后返回到屏幕上的第一个 EditText
?
例如:
注意,右下角显示“下一步”。我希望它像这样说“ Next”而不是“ Done”,并且我还希望它在我按“ Next”时返回(专注于)a EditText
,当前专注于c EditText
。
在c的EditText
XML属性中,将此属性添加到其中:EditText
android:imeOptions="actionNext"
这样可以使软键盘的右下角是“下一步”按钮,而不是“完成”按钮。
然后,为在EditText
c上按下“下一步”按钮设置监听器。
EditText a = (EditText)findViewById(R.id.a);
EditText c = (EditText)findViewById(R.id.c);
c.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event)
{
// if the user pressed the "Next" button on the soft keyboard
if(actionId==EditorInfo.IME_ACTION_NEXT)
{
a.requestFocus(); // change the focus to the 'a' EditText
}
return true; // keep the keyboard up
}
});
就是这样。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句