【发布时间】:2017-06-17 19:15:58
【问题描述】:
我创建了虚拟键盘,我必须在其中收到有关特定应用程序是否支持提交内容 api 的通知?
由于我在键盘内使用自定义图像,因此需要进行此项检查。
我正在使用 InputMethodService 并且它已经在演示应用程序中完成以检查以下内容:
@Override
public void onStartInputView(EditorInfo info, boolean restarting) {
mGifButton.setEnabled(mGifFile != null && isCommitContentSupported(info, MIME_TYPE_GIF));
mPngButton.setEnabled(mPngFile != null && isCommitContentSupported(info, MIME_TYPE_PNG));
mWebpButton.setEnabled(mWebpFile != null && isCommitContentSupported(info, MIME_TYPE_WEBP));
}
在这里,在上面的代码中,带有“m”首字母的变量是按钮。
并且方法 onStartInputView 被覆盖,其中它检查支持 api,如果支持,则按钮将被启用。
没关系,如果不支持,按钮将被禁用并将其颜色更改为浅暗。现在,由于我使用的是 GridView,所以我做了如下操作:
@Override
public void onStartInputView(EditorInfo info, boolean restarting) {
Log.e(">>>>>>Editor Info : >> ",""+info);
grid.setEnabled(imageFile1 != null && isCommitContentSupported(info, MIME_TYPE_PNG));
}
已完成,但如何用户会收到不支持此功能的通知。因为 GridView 不会更改其颜色或 UI,因此用户会知道这不起作用。
setEnabled 的返回类型为 void。
那么,这怎么可能?
【问题讨论】:
标签: android gridview keyboard android-input-method