我有一个扩展AppCompatActivity的活动。此活动包含工具栏,TabLayout和ViewPager。 我使用带有progressdialog的AsyncTask,我的问题是缺少progressdialog旋转圆圈。
当我从没有工具栏,TabLayout和ViewPager的Activity调用AsyncTask时,旋转圈不会丢失。
谢谢。
public class YiOptionalInfoActivity extends AppCompatActivity implements View.OnClickListener, YiAsyncTaskListener{
private Toolbar toolbar;
private TabLayout tabLayout;
private ViewPager viewPager;
private Button mBtnNext = null;
private YiAsyncTask mAsyncTask = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.optional_screen);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
//getSupportActionBar().setTitle(R.string.optional_info);
getSupportActionBar().setDisplayShowTitleEnabled(false);
viewPager = (ViewPager) findViewById(R.id.viewpager);
setupViewPager(viewPager);
tabLayout = (TabLayout) findViewById(R.id.tabs);
tabLayout.setupWithViewPager(viewPager);
setupTabIcons();
}
public class YiAsyncTask extends AsyncTask<Integer, Void, Boolean> {
private final String TAG = YiAsyncTask.class.getSimpleName();
/** progress dialog to show user that the backup is processing. */
private ProgressDialog mProgressDialog = null;
/** application context. */
private Context mContext = null;
public YiAsyncTask(Context context) {
this.mContext = context;
}
protected void onPreExecute() {
super.onPreExecute();
mProgressDialog = this.mProgressDialog.show(mContext, mContext.getString(R.string.app_name), mContext.getString(R.string.task_processing), true);
}
@Override
protected void onPostExecute(final Boolean success) {
if (null != mProgressDialog && mProgressDialog.isShowing()) {
mProgressDialog.dismiss();
mProgressDialog = null;
}
}
@Override
protected Boolean doInBackground(Integer... params) {
}