Android:InputMethodService如何使用setExtractView(View view)设置视图?
我正在尝试为全屏模式下的自定义 Android 键盘提供修改后的视图。因此我试图替换提取视图。在文档中我找到了以下方法: setExtractView(View view) - 所以我假设这是一个公共 API 调用。
但是,正如您从 Android 操作系统源代码(下面粘贴的片段)中看到的那样,它只允许我访问具有 com.android.internal.* 空间内 id 的视图项目的视图。否则,我当然会得到一个 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 的自定义视图?
更新:没关系,刚刚发现这个。稍后会检查并报告是否有效。
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.
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;
}
}
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有点晚了,但答案仍然在这里(感谢塞缪尔给我打电话)。解决方案其实很简单:
A bit late, but still here the answer (thanks Samuel for pinging me). The solution is actually quite simple: