【问题标题】:How to mimic Google Keyboard's spacebar long-press functionality for switching keyboards?如何模仿谷歌键盘的空格键长按功能来切换键盘?
【发布时间】:2016-02-13 05:21:48
【问题描述】:

Google 键盘可让您在 Android 中长按空格键来切换键盘。我没有通过 Google 搜索找到任何结果,但我确信有办法以编程方式完成此操作。

如何调出输入法选择器?

【问题讨论】:

  • 我刚刚尝试在我的 Nexus 6P 上长按空格键,但它并没有做任何特别的事情。
  • @dougstevenson 谷歌键盘。我有同样的设备。

标签: android android-layout android-keypad


【解决方案1】:

他们使用showInputMethodPicker():

private void onSpaceBarLongPress() {
    InputMethodManager imm = (InputMethodManager)
        getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showInputMethodPicker();
}

【讨论】:

  • 第一条语句产生Incompatible types编译错误。
  • 添加了适当的演员表
  • 太棒了。感谢您的迅速回复。
  • 我知道这是一个迟到的回应,但你知道我如何在InputMethodService 中实现这一点吗?我没有看到内置的 onLongPress 事件。
  • @shruggernaut - 扩展 KeyboardView 并覆盖 onLongPress()?
猜你喜欢
  • 2012-10-16
  • 2020-06-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-06-24
  • 2015-06-06
  • 2012-03-03
  • 2011-08-02
相关资源
最近更新 更多