2011-03-27 41 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(); 
     }