Android-prevent Dismissal Of Dropdown In Autocompletetextview After Item Selection
Solution 1:
I also want to implement the same i used below code to implement it.
Create a custom class and extend AutoCompleteTextView.
Override dismissDropDown() method and remove the super call from it. Will work for you.
publicclassCustomAutoCompleteextendsAutoCompleteTextView {
publicNoSelectionAutoComplete(Context context) {
super(context);
}
publicNoSelectionAutoComplete(Context context, AttributeSet attrs) {
super(context, attrs);
}
publicNoSelectionAutoComplete(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@OverrideprotectedvoidreplaceText(CharSequence text) {
}
@OverridepublicvoiddismissDropDown() {
}
}
Solution 2:
I added an onClickListener to the entire custom row layout that I was using for the dropdown adapter. This way whenever the row is clicked, my row onClickListener is invoked and the default one for the dropdown is not.
Solution 3:
First Question - Prevent dropdown dismissal:
Solved below.
Second Question - Prevent text replacement: (For others interested)
You can extend AutoCompleteTextView and override
protectedvoidreplaceText(CharSequence text) {}
to do nothing.
As others mentioned, overriding performCompletion() won't help here.
Solution 4:
well at least it seems like they are planning to add this in near future.
/**
* Sets whether the drop-down should remain visible as long as there is there is
* {@link #enoughToFilter()}. This is useful if an unknown number of results are expected
* to show up in the adapter sometime in the future.
*
* The drop-down will occupy the entire screen below {@link #getDropDownAnchor} regardless
* of the size or content of the list. {@link #getDropDownBackground()} will fill any space
* that is not used by the list.
*
* @param dropDownAlwaysVisible Whether to keep the drop-down visible.
*
* @hide Pending API council approval
*/publicvoid setDropDownAlwaysVisible(boolean dropDownAlwaysVisible) {
mPopup.setDropDownAlwaysVisible(dropDownAlwaysVisible);
}
Solution 5:
edit,new answer: this worked for me but it closes for a sec,and opens again.
classtaskextendsTimerTask {
@Overridepublicvoidrun() {
runOnUiThread(newRunnable() {
@Overridepublicvoidrun() {
autoComplete.showDropDown();
}
});
}
};
autoComplete.setOnItemClickListener(newOnItemClickListener() {
publicvoidonItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
newTimer().schedule(newtask(),0, 10);
}
});
Post a Comment for "Android-prevent Dismissal Of Dropdown In Autocompletetextview After Item Selection"