在函数pickSuggestionManually(int index)
中
评论文档说明如下:
// If we were generating candidate suggestions for the current
// text, we would commit one of them here. But for this sample,
// we will just commit the current text.
commitTyped(getCurrentInputConnection());
现在,如何提交其中一个候选建议?
有人可以帮忙吗?
此致 Sayantan
答案 0 :(得分:5)
添加如下功能:
public String getSuggestion(int index)
{
return index >= 0 && mSuggestions != null && index < mSuggestions.size() ? mSuggestions.get(index) : "";
}
到CandidateView.java,然后将您引用的代码替换为:
if (mCandidateView != null) {
getCurrentInputConnection().commitText(
mCandidateView.getSuggestion(index),
mCandidateView.getSuggestion(index).length());
mComposing.setLength(0);
updateCandidates();
}