【发布时间】:2011-04-30 21:50:26
【问题描述】:
我正在尝试为全屏模式下的自定义 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 的自定义视图?
更新:没关系,刚刚找到this。稍后会检查并报告它是否有效。
【问题讨论】:
-
你有没有得到这个工作?
-
感谢塞缪尔提醒我。我刚刚发布了我的解决方案。
标签: android view input keyboard