тебе все еще нужны идеи для этого? Я реализовал то же самое в своем приложении, но не в виде диалога, у меня было два макета, которые перекрывают друг друга. Затем я переключаюсь между двумя макетами, устанавливая видимость .setVisibility()
. Что касается самого индикатора выполнения, я использую это:
РЕДАКТИРОВАТЬ : Вот весь мой XML-файл:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="@drawable/background">
<RelativeLayout android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/search_header" android:background="@drawable/header">
<!-- Some things I need for the header (title, etc) -->
</RelativeLayout>
<LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content"
android:id="@+id/spinner_layout" android:layout_below="@+id/search_header"
android:layout_centerHorizontal="true" android:layout_centerVertical="true">
<ProgressBar android:id="@+id/title_progress_bar"
style="?android:attr/progressBarStyleSmallTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:visibility="visible"
android:indeterminateOnly="true"/>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/loading_label" android:text="Loading..."
android:layout_gravity="center_vertical" android:layout_marginLeft="5dip">
</TextView>
</LinearLayout>
<RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/search_header" android:id="@+id/list_contents">
<!-- Stuff you want to show after returning from the AsyncTask -->
</RelativeLayout>
</RelativeLayout>
Я использую этот макет для Activity
с AsyncTask
, поэтому onPreExecute()
, я делаю что-то вроде:
@Override
protected void onPreExecute(){
findViewById(R.id.list_contents).setVisibility(View.GONE);
findViewById(R.id.spinner_layout).setVisibility(View.VISIBLE);
}
А потом делай, что мне нужно, и onPostExecute()
У меня есть:
@Override
protected void onPostExecute(Cursor cursor){
findViewById(R.id.list_contents).setVisibility(View.VISIBLE);
findViewById(R.id.spinner_layout).setVisibility(View.GONE);
}