解决方法
I would like to show loading indicator in AutoCompleteTextView while
loading data from web-service.
在窗口小部件的右侧放置一个带有不确定外观的ProgressBar,并像这样扩展AutoCompleTextView类:
public class AutoCompleteLoadding extends AutoCompleteTextView { private ProgressBar mLoadingIndicator; public void setLoadingIndicator(ProgressBar view) { mLoadingIndicator = view; } @Override protected void performFiltering(CharSequence text,int keyCode) { // the AutoCompleteTextview is about to start the filtering so show // the ProgressPager mLoadingIndicator.setVisibility(View.VISIBLE); super.performFiltering(text,keyCode); } @Override public void onFilterComplete(int count) { // the AutoCompleteTextView has done its job and it's about to show // the drop down so close/hide the ProgreeBar mLoadingIndicator.setVisibility(View.INVISIBLE); super.onFilterComplete(count); } }
使用setLoadingIndicator()方法将引用传递给ProgressBar.这假设您在适配器(AutoCompleteTextView)/适配器的过滤器中发出Web服务请求.