2011-03-27 42 views
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()); 

现在,如何提交的候选人建议吗?

任何人都可以帮忙吗?

问候, Sayantan

回答

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(); 
     }