I use the following code to set text to an AutoCompleteTextView field. But I noticed that when I set certain text (not all text, but some) to it, it will automatically pop u
Maybe it is to late, but I've found elegant solution for this problem:
Disable filtering before setting text and enabling it after (instead of playing with focus or/and delays). You should use custom control in this case.
See example below:
public class CustomCompliteTextView extends AutoCompleteTextView {
private boolean mIsSearchEnabled = true;
public CustomCompliteTextView(Context context) {
super(context);
}
public CustomCompliteTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public CustomCompliteTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public void setSearchEnabled(boolean isEnabled) {
mIsSearchEnabled = isEnabled;
}
@Override
protected void performFiltering(CharSequence text, int keyCode) {
if (mIsSearchEnabled) {
super.performFiltering(text, keyCode);
}
}
}
And usage:
text.setSearchEnabled(false);
text.setText("Text you want to set");
// optional, if you also want to set correct selection
text.setSelection(text.getText().length());
text.setSearchEnabled(true);