android 输入法界面显示的开关



进入InputMethodManager类的doStartInput方法

    void doStartInput(InputConnection ic, EditorInfo attribute, boolean restarting) {
        if (!restarting) {
            doFinishInput();
        }
        mInputStarted = true;
        mStartedInputConnection = ic;
        mInputEditorInfo = attribute;
        initialize();
        if (DEBUG) Log.v(TAG,"InputMethodService class" +  "CALL: onStartInput , mWindowVisible=" + mWindowVisible);
        onStartInput(attribute, restarting);
        if (mWindowVisible) {
            if (mShowInputRequested) {
                if (DEBUG) Log.v(TAG,"InputMethodService class" +  "CALL: onStartInputView");
                mInputViewStarted = true;
                onStartInputView(mInputEditorInfo, restarting);
                startExtractingText(true);
            } else if (mCandidatesVisibility == View.VISIBLE) {
                if (DEBUG) Log.v(TAG,"InputMethodService class" +  "CALL: onStartCandidatesView");
                mCandidatesViewStarted = true;
                onStartCandidatesView(mInputEditorInfo, restarting);
            }
        }
    }

从上面来看mWindowVisible这个变量就是开关,那么我们来看下,这个变量是什么时候true的呢?即上面时候才让它show的呢?

找到两处赋值的地方,如下:

   void showWindowInner(boolean showInput) {
        boolean doShowInput = false;
        boolean wasVisible = mWindowVisible;
        mWindowVisible = true;
    public void hideWindow() {
        finishViews();
        mImm.setImeWindowStatus(mToken, 0, mBackDisposition);
        if (mWindowVisible) {
            mWindow.hide();
            mWindowVisible = false;
            onWindowHidden();
            mWindowWasVisible = false;
        }
    }

我们看下showWindowInner在什么地方被调用

    public void showWindow(boolean showInput) {
        if (DEBUG) Log.v(TAG,"InputMethodService class" +  "Showing window: showInput=" + showInput
                + " mShowInputRequested=" + mShowInputRequested
                + " mWindowAdded=" + mWindowAdded
                + " mWindowCreated=" + mWindowCreated
                + " mWindowVisible=" + mWindowVisible
                + " mInputStarted=" + mInputStarted);
        
        if (mInShowWindow) {
            Log.w(TAG,"InputMethodService class" +  "Re-entrance in to showWindow");
            return;
        }
        
        try {
            mWindowWasVisible = mWindowVisible;
            mInShowWindow = true;
            showWindowInner(showInput);
        } finally {
            mWindowWasVisible = true;
            mInShowWindow = false;
        }
    }

        public void showSoftInput(int flags, ResultReceiver resultReceiver) {
            if (DEBUG) Log.v(TAG,"InputMethodService class" +  "showSoftInput()");
            boolean wasVis = isInputViewShown();
            mShowInputFlags = 0;
            if (onShowInputRequested(flags, false)) {
            	if (DEBUG) Log.v(TAG,"InputMethodService class" +  "showWindow(true)");
                showWindow(true);
            }

从上面来看,它的确是传了个true,showWindow(true);那么什么时候才周到这里呢?看了下日志,如下:

01-01 09:22:22.520 V/PateoInputMethod( 1486): InputMethodService classshowSoftInput()
01-01 09:22:22.520 V/PateoInputMethod( 1486): InputMethodService classshowWindow(true)

可以看出是在show的时候进入该方法的,那就对了,好吧,有关怎么show的流程,可以看我写的另一个帖子:

 

android 点击输入框调出输入法流程分析


http://blog.csdn.net/jianguo_liao19840726/article/details/24413043



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值