我以前没见过这个,我只是想明白了,所以我想我会写这个 QnA。如果您认为这是重复的,请告诉我。
问题:
我怎样才能做到当用户关注屏幕上的 last EditText
时,它会为他们提供软键盘上的选项以按 < strong>Next 然后会回到屏幕上的first EditText
吗?
例如:
右下角的通知是“下一步”。我希望它像那样说“下一步”而不是“完成”,我还希望它在我按下“下一步”时返回(专注于)a EditText
,目前专注于 c EditText
。
最佳答案
在 EditText
c 的 EditText
XML 属性中,将此属性添加到其中:
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
}
});
就是这样。
关于java - 如何在屏幕最后一个EditText上按 "Next"返回到第一个EditText,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19987082/