在ActionBar(Android)中使用ProgressDialog
我正在尝试将ProgressDialog移动到我的ActionBar 我知道如何将其放在动作栏中并设置动画(我认为),如下所示: In progress.xml在ActionBar(Android)中使用ProgressDialog,android,android-actionbar,progressdialog,Android,Android Actionbar,Progressdialog,我正在尝试将ProgressDialog移动到我的ActionBar 我知道如何将其放在动作栏中并设置动画(我认为),如下所示: In progress.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" andr
<?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>
以下是我在AsyncTask的onPreExecute
和onPostExecute
中的当前PD(在活动中):
// Pre
dialog = new MyProgressDialog(---.this);
dialog.show(---.this);
// Post
dialog.dismiss(---.this);
那么我如何移动它,以便在onPreExecute
中激活操作栏指示器,然后在onPostExecute
中停止
编辑:我不仅在寻找刷新,而且在你第一次加载一个活动(或者做一些需要PD激活的事情)时,还需要一个“加载”指示器。默认情况下,它应该是隐藏的。我想我必须回答我自己的问题。这其实很简单 在活动中,就在
setContentView
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
AsyncTask
// pre
setProgressBarIndeterminateVisibility(true);
// Get Data
// post
setProgressBarIndeterminateVisibility(false);
如果必须在onCreate()中输入 或者,如果您使用的是支持包
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setSupportProgressBarIndeterminateVisibility(true);
如果您发现任何问题,请发表评论。编辑后,我认为标题与问题不再匹配。
// pre
setProgressBarIndeterminateVisibility(true);
// Get Data
// post
setProgressBarIndeterminateVisibility(false);
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setProgressBarIndeterminateVisibility(true);
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setSupportProgressBarIndeterminateVisibility(true);