从 InputMethodService 扩展的类中消除视图

发布于 2024-12-14 17:54:20 字数 465 浏览 0 评论 0原文

我创建了一个自定义键盘。键盘不是 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凉城 2024-12-21 17:54:29

如果 keyboard 是您想要隐藏的 View,请尝试调用 keyboard.setVisibility(View.GONE)。如果你想完全删除它,你必须找到 keyboard 的父视图并调用 removeView(keyboard) 。我认为第一种方法更简单,具体取决于你想要什么。

Well if keyboard is the View you want to hide, try calling keyboard.setVisibility(View.GONE). If you want to remove it entirely you would have to find the parent view of keyboard and call removeView(keyboard) on that. I think the first approach is simpler though, depending on what you want.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文