【发布时间】:2012-09-30 15:37:13
【问题描述】:
我正在尝试将 ProgressDialog 移动到我的 ActionBar。
我知道如何将它放在操作栏中并为其设置动画(我认为),如下所示:
进行中.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;
这是我当前的 PD(在活动中)在我的 AsyncTask 的 onPreExecute 和 onPostExecute:
// Pre
dialog = new MyProgressDialog(---.this);
dialog.show(---.this);
// Post
dialog.dismiss(---.this);
那么我该如何移动它,以便在onPreExecute 中激活操作栏指示器,然后在onPostExecute 中停止?
编辑:我不仅在寻找刷新,而且在您首次加载活动(或执行需要 PD 激活的操作)时寻找“加载”指示器。默认情况下应该是隐藏的。
【问题讨论】:
-
编辑后,标题不再匹配问题,我想。
标签: android android-actionbar progressdialog