Skip to content

Instantly share code, notes, and snippets.

@tushroy
Last active December 30, 2015 12:29
Show Gist options
  • Save tushroy/7829127 to your computer and use it in GitHub Desktop.
Save tushroy/7829127 to your computer and use it in GitHub Desktop.
AutoCompleteTextView the suggestions will be limited. but since the method used in base class is private can't override it in child.
private void buildImeCompletions() {
final int limit_result=20;
//change the limit_result value
final ListAdapter adapter = mAdapter;
if (adapter != null) {
InputMethodManager imm = InputMethodManager.peekInstance();
if (imm != null) {
final int count = Math.min(adapter.getCount(), limit_result);
CompletionInfo[] completions = new CompletionInfo[count];
int realCount = 0;
for (int i = 0; i < count; i++) {
if (adapter.isEnabled(i)) {
Object item = adapter.getItem(i);
long id = adapter.getItemId(i);
completions[realCount] = new CompletionInfo(id, realCount,
convertSelectionToString(item));
realCount++;
}
}
if (realCount != count) {
CompletionInfo[] tmp = new CompletionInfo[realCount];
System.arraycopy(completions, 0, tmp, 0, realCount);
completions = tmp;
}
imm.displayCompletions(this, completions);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment