如何在viewflipper上自动将键盘放在前面?

时间:2013-09-05 08:15:29

标签: java android keyboard viewflipper

我有一个有很多viewflippers的活动,想要自动将edittext的键盘放到前面。当我开始活动时,它在逻辑上工作一次。有了这个:

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

或清单中的此内容:

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

那么如何在活动开始时获取此信息并使用edittext返回viewflipper?

1 个答案:

答案 0 :(得分:0)

试试这个

要显示键盘时调用此方法

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();
        }
    }