I do not have a positive answer to the question (I think it is not possible). But I use a workaround to reach the same goal (find AutoCompleteTextView
from within onItemClick):
I defined the following class, which can be used to modify the onItemClick
call to provide the AutoCompleteTextView
as second parameter (instead of original View
param).
public class AutoCompleteTextViewClickListener implements OnItemClickListener {
AutoCompleteTextView mAutoComplete;
OnItemClickListener mOriginalListener;
public AutoCompleteTextViewClickListener(AutoCompleteTextView acTextView,
OnItemClickListener originalListener) {
mAutoComplete = acTextView;
mOriginalListener = originalListener;
}
public void onItemClick(AdapterView<?> adView, View view, int position,
long id) {
mOriginalListener.onItemClick(adView, mAutoComplete, position, id);
}
}
This can be used in the following way:
Instead of
myTextView.setOnItemClickListener(myListener);
you'll have to write:
myTextView.setOnItemClickListener(
new AutoCompleteTextViewClickListener(myTextView, myListener));
Now, whenever onItemClicked is triggered by the TextView, instead of the original view value the reference to the AutoCompleteTextView is available.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…