Web サービスからデータをロードしているときに、AutoCompleteTextView にロード インジケータを表示したいと思います。できれば、オートコンプリートの右側に表示する必要があります (進行中のコントロールのような fi アニメーション - 糸車)。これはどのように行うことができますか?
4815 次
3 に答える
7
Web サービスからデータをロードしているときに、AutoCompleteTextView にロード インジケータを表示したいと思います。
ウィジェット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);
}
}
メソッドProgressBar
でへの参照を渡します。これは、アダプター (の)/アダプターのフィルターsetLoadingIndicator()
で Web サービス要求を行っていることを前提としています。AutoCompleteTextView
于 2013-03-14T09:39:03.210 に答える
1
スピナーではなく進行状況バーを使用したい。グラフィカル ビューを使用して AutoCompleteTextView フィールドの上に配置し、ID を設定します。私はprogressLoadingに設定しました。
<ProgressBar
android:id="@+id/progressLoading"
style="?android:attr/progressBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/autoCompleteTextViewId"
android:layout_alignTop="@+id/autoCompleteTextViewId"
android:paddingTop="14dip"
android:paddingRight="10dip" />
次に、アクティビティ/フラグメントで:
final ProgressBar barProgress = (ProgressBar) findViewById(R.id.progressLoading);
originProgress.setVisibility(View.GONE);
自動的に表示されるため、最初は非表示に設定しています。次に、AutoCompleteTextView の addTextChangedListener で VISIBLE に設定します。次に、そのタスクが完了するたびに、非表示に戻します。
于 2013-10-20T23:58:27.697 に答える