如何解决如何使用android景观键盘按钮?
| 我有一个带有两个EditText的活动。如果在横向模式下选择第一个EditText,则显示的键盘上有一个“下一步”按钮,该按钮应允许我键入第二个EditText。同样,第二个EditText具有一个“完成”按钮,我想使用它完成活动。如何处理这些按钮的选择?解决方法
关于如何解决此问题的文档很少。我在这里找到了一个很好的解决方案。基本上,您可以为每个EditText添加IMEoption:
对于第一个:
android:imeOptions=\"actionNext\"
对于第二个:
android:imeOptions=\"actionDone\"
要在代码中处理这些,请尝试如下操作:
EditText departureAddress,destinationAddress;
departureAddress = (EditText)findViewById(R.id.departure);
//Set the action of the \"next\" button to bring destinationAddress to focus
destinationAddress(new OnEditorActionListener(){
@Override
public boolean onEditorAction(TextView v,int actionId,KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_NEXT) {
destinationAddress.requestFocus();
}
return true;
}
});
destinationAddress = (EditText)findViewById(R.id.destination);
//Set the action of the \"done\" button to handle the map query
destinationAddress.setOnEditorActionListener(new OnEditorActionListener(){
@Override
public boolean onEditorAction(TextView v,KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
//Handle map query
}
return true;
}
});
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。