如何改变标签时,我隐藏软键盘? [英] How do I hide the soft keyboard when changing tabs?

查看:141
本文介绍了如何改变标签时,我隐藏软键盘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑:好像我没有让自己清楚。我需要的是隐藏软键盘,每当我代替我在片段的方式。我怎么会去这样做?

让我保持这个简单。我在标签片段1.2一个EditText盒这显然打开的时候运pressed软键盘。如何隐藏这个当标签被改变?我想在我的onTabSelected(),它似乎并没有做任何事情,以下

Let me keep this simple. I have an EditText box in Tab Fragment 1.2 which obviously opens op the Soft keyboard when pressed. How do I hide this when the tab is changed? I tried the following in my onTabSelected() which doesn't seem to do anything

getWindow().setSoftInputMode(
                  WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

现在我已经用尽了一切办法。建议的解决方案我已经位于到目前为止都帮助我以任何方式,都没有

I've tried everything now. None of the suggested solutions I've located so far are helping me in any way.

推荐答案

编程可以使用,捕捉活跃活动的视频播放设备的屏幕上。

programmatically you could use, capturing the view of the active activity on the screen of the device.

public final void onTabReselected(Tab tab, FragmentTransaction fragmentTransaction) {
        View focus = getCurrentFocus();
        if (focus != null) {
            hiddenKeyboard(focus);
        }
    }
public final void onTabselected(Tab tab, FragmentTransaction fragmentTransaction) {
        View focus = getCurrentFocus();
        if (focus != null) {
            hiddenKeyboard(focus);
        }
    }
public final void onTabUnselected(Tab tab, FragmentTransaction fragmentTransaction) {
        View focus = getCurrentFocus();
        if (focus != null) {
            hiddenKeyboard(focus);
        }
    }

private void hiddenKeyboard(View v) {
        InputMethodManager keyboard = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        keyboard.hideSoftInputFromWindow(v.getWindowToken(), 0);
    }

这篇关于如何改变标签时,我隐藏软键盘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆