Android:InputMethodService如何使用setExtractView(View view)设置视图? [英] Android: InputMethodService how to set a view with setExtractView(View view)?

查看:333
本文介绍了Android:InputMethodService如何使用setExtractView(View view)设置视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试以全屏模式为自定义Android键盘提供修改后的视图.因此,我正在尝试替换提取视图.在文档中,我找到了以下方法: setExtractView(View view)-因此,我认为这是一个公共API调用.

I'm trying to provide a modified view for a custom Android keyboard in fullscreen mode. Therefor I'm trying to replace the extract view. In the documentation I found the following method: setExtractView(View view) - so I assume it's a public API call.

但是,正如您从Android OS源代码中看到的(粘贴在下面),它仅允许我访问在com.android.internal.*空间内具有ID为ID的视图项的视图.否则,我当然会得到NullPointerException.

However, as you can see from the Android OS source code (snipped pasted below) it lets me only access a view that has view items with id's within the com.android.internal.* space. Otherwise I will, of course, get a NullPointerException.

public void setExtractView(View view) {
    mExtractFrame.removeAllViews();
    mExtractFrame.addView(view, new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    mExtractView = view;
    if (view != null) {
        mExtractEditText = (ExtractEditText)view.findViewById(
                com.android.internal.R.id.inputExtractEditText);
        mExtractEditText.setIME(this);
        mExtractAction = (Button)view.findViewById(
                com.android.internal.R.id.inputExtractAction);
        if (mExtractAction != null) {
            mExtractAccessories = (ViewGroup)view.findViewById(
                    com.android.internal.R.id.inputExtractAccessories);
        }
        startExtractingText(false);
    } else {
        mExtractEditText = null;
        mExtractAccessories = null;
        mExtractAction = null;
    }
}

那么,我想知道这是一个错误吗?该方法是否在公共API中?如果没有,我如何在com.android.internal.*空间中创建具有ID的自定义视图?

So, I'm wondering, is it a bug, that this method is within the public API or if not, how can I create a custom view with IDs in the com.android.internal.* space?

更新:没关系,只是找到了.稍后将检查并报告是否有效.

Update: Nevermind, just found this. Will check later and report back if it worked.

推荐答案

有点晚了,但仍然是答案(感谢Samuel对我执行ping命令).解决方案实际上很简单:

A bit late, but still here the answer (thanks Samuel for pinging me). The solution is actually quite simple:

ExtractEditText extractEditTextView = new ExtractEditText(this);
extractEditTextView.setId(android.R.id.inputExtractEditText);

这篇关于Android:InputMethodService如何使用setExtractView(View view)设置视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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