android – 如何将加载指示符添加到AutoCompleteTextView

前端之家收集整理的这篇文章主要介绍了android – 如何将加载指示符添加到AutoCompleteTextView前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想在从Web服务加载数据时在AutoCompleteTextView中显示加载指示器.优选地,它应该显示自动完成的右侧(f.i.动画像进行中控制 – 旋转轮).怎么做到这一点?

解决方法

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服务请求.

原文链接:https://www.f2er.com/android/309548.html

猜你在找的Android相关文章