从 InputMethodService 扩展的类中消除视图
我创建了一个自定义键盘。键盘不是 Keyboard 类的扩展,也不使用 Keyboard View 类。我已经成功创建了键盘,因此它会弹出。键盘是我从 xml 文件创建的 LinearLayout。问题是:我无法摆脱它。
如果它是 KeyboardView 的扩展,我会使用
keyboard.closing();
,但由于它是 LinearLayout,我没有该方法。
然后我尝试了一下
keyboard.removeView(keyboard);
,没想到这会起作用,但事实并非如此。
最后,我尝试
keyboard.removeAllViews();
希望它能在屏幕上留下键盘,但如果删除所有视图,没有人会拒绝。这也不起作用。
有什么建议吗?
I am created a custom keyboard. The keyboard is NOT an extension of the Keyboard class and does not use the Keyboard View class either. I have successfully created my keyboard so that it popups up. The keyboard is a LinearLayout I created from an xml file. Here is the problem: I can't get rid of it.
If it was an extension of KeyboardView, I would use
keyboard.closing();
but since its a LinearLayout, I don't have that method.
I then tried
keyboard.removeView(keyboard);
I didn't expect this to work, and it didn't.
Finally, I tried
keyboard.removeAllViews();
in hopes that it would sort of leave keyboard on the screen, but no one would no if all the views were removed. This did not work either.
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果
keyboard
是您想要隐藏的 View,请尝试调用keyboard.setVisibility(View.GONE)
。如果你想完全删除它,你必须找到keyboard
的父视图并调用removeView(keyboard)
。我认为第一种方法更简单,具体取决于你想要什么。Well if
keyboard
is the View you want to hide, try callingkeyboard.setVisibility(View.GONE)
. If you want to remove it entirely you would have to find the parent view ofkeyboard
and callremoveView(keyboard)
on that. I think the first approach is simpler though, depending on what you want.