我正在尝试将ProgressDialog移动到我的ActionBar中。
我知道如何将它放在操作栏中并进行动画处理(我认为是这样的),像这样:
在progress.xml文件中:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1" >
<ProgressBar
android:id="@+id/progress"
style="?android:attr/progressBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</ProgressBar>
</LinearLayout>
在menu.xml中
<item
android:id="@+id/Refresh"
android:icon="@drawable/ic_menu_refresh"
android:showAsAction="always"
android:title="Refresh"/>
在我的活动中
case R.id.Refresh:
item.setActionView(R.layout.progress);
return true;
以下是我AsyncTask中onPreExecute
和onPostExecute
方法的当前PD(活动):
// Pre
dialog = new MyProgressDialog(---.this);
dialog.show(---.this);
// Post
dialog.dismiss(---.this);
那么我该如何移动这个进度条,使得在onPreExecute
中激活操作栏指示器,并在onPostExecute
中停止?
编辑:我不仅要求刷新,还需要在首次加载活动(或执行需要激活PD的操作)时显示“加载”指示器。它应该默认隐藏。