当前事件完成后调度 KeyEvent?
我有一个 OnKeyListener(),位于扩展 EditText 的类中,当按下 Enter 键时,检查行末尾的某个字符,如果存在,则调度另一个 KeyEvent 将选项卡按下发送回 EditText 。但发生的情况是它添加了选项卡,然后创建了一个新行。创建新行后我需要该选项卡。在 OnKeyListener()/OnKey() 方法之后是否会触发任何我可以放置“选项卡事件”的内容?或者其他方式? 谢谢。
I have an OnKeyListener(), living in a class that extends an EditText, that when the enter key is pressed checks for a certain character at the end of the line and if it exists dispatches another KeyEvent to send a tab press back to the EditText. But what is happening is it adds the tab and then creates a new line. I need the tab after the new line is created. Is there anything that gets triggered after the OnKeyListener()/OnKey() methods that I could put my "tab event"? Or another way?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在 onKey 方法中附加换行符和制表符,然后返回 true 来指示该事件已被消耗,以防止随后处理原始换行符。
将 shouldAppendTab(editableText) 替换为您的代码,以确定是否要附加该选项卡。
You could append the linefeed and tab in your onKey method and then return true to indicate that the event has been consumed to prevent the original linefeed from being processed afterward.
Replace shouldAppendTab(editableText) with your code for determining whether you want the tab to be appended.