1

在函数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());

现在,如何提交候选建议之一?

有人可以帮忙吗?

问候, 萨扬坦

4

1 回答 1

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();
        }
于 2011-04-24T14:31:11.823 回答