【问题标题】:How can I bring the keyboard into front automatically on a viewflipper?如何在取景器上自动将键盘放在前面?
【发布时间】:2013-09-05 08:15:29
【问题描述】:

我有一个包含许多 viewflippers 的活动,并希望自动将 edittext 的键盘放在前面。当我开始活动时,它在逻辑上工作一次。有了这个:

this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);

或者清单中的这个:

  <activity
        android:windowSoftInputMode="stateVisible|adjustResize">

那么当 Activity 已经启动并返回带有编辑文本的 viewflipper 时,我该如何获取呢?

【问题讨论】:

标签: java android keyboard viewflipper


【解决方案1】:

试试这个

当你想显示键盘时调用这个方法

public void showSoftKeyboard() {
        try {
            InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
            inputMethodManager.toggleSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.SHOW_FORCED, 0);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

【讨论】:

  • 非常感谢!你知道当你按下键盘上的回车键时如何做一个动作吗?
猜你喜欢
  • 1970-01-01
  • 2011-11-18
  • 1970-01-01
  • 2014-01-10
  • 2011-01-17
  • 1970-01-01
  • 2019-07-04
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多