Last active
December 30, 2015 12:29
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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