下面列出了android.app.ProgressDialog#setProgressStyle ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public AbstractCreationTask(final Context context, final CreationFinishedListener listener) {
this.context = context;
this.listener = listener;
progressDialog = new ProgressDialog(context, ProgressDialog.THEME_HOLO_DARK);
progressDialog.setTitle("Batch creation");
progressDialog.setMessage(dialogMsg());
progressDialog.setCancelable(true);
progressDialog.setCanceledOnTouchOutside(false);
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressDialog.setMax(times());
progressDialog.setProgress(0);
if (times() == 1) {
progressDialog.setIndeterminate(true);
} else {
progressDialog.setIndeterminate(false);
}
}
@Override
protected void onPreExecute() {
if (doProgress) {
progressDialog = new ProgressDialog(context);
if (title == null) {
progressDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
} else {
progressDialog.setTitle(title);
}
progressDialog.setMessage(message);
progressDialog.setCancelable(cancelable);
if (max == null) {
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progressDialog.setIndeterminate(true);
} else {
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressDialog.setIndeterminate(false);
progressDialog.setProgress(0);
progressDialog.setMax(max);
}
progressDialog.show();
}
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final ProgressDialog dialog = new ProgressDialog(getActivity());
//
Bundle b = getArguments();
if (b != null) {
String title = b.getString("title");
String content = b.getString("content");
dialog.setTitle(title);
dialog.setMessage(content);
}
//dialog.setCanceledOnTouchOutside(true);
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
dialog.setIndeterminate(true);
//dialog.setCancelable(true);
// etc...
this.setStyle(DialogFragment.STYLE_NO_FRAME, android.R.style.Theme);
return dialog;
}
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
ProgressDialog progressDialog = new ProgressDialog(getActivity());
progressDialog.setMessage(getString(R.string.rotate_the_device));
progressDialog.setCancelable(false);
progressDialog.setIndeterminate(false);
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(android.R.string.cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (mTaskId != -1) {
SimpleTask task = (SimpleTask) TaskExecutor.getInstance().getTask(mTaskId);
if (task != null) {
task.cancel();
}
}
}
});
return progressDialog;
}
@Override
protected void loadData() {
final ProgressDialog dialog = new ProgressDialog(this);
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
dialog.setCancelable(false);
dialog.setMessage("Loading");
dialog.show();
new ListFolderTask(DropboxClientFactory.getClient(), new ListFolderTask.Callback() {
@Override
public void onDataLoaded(ListFolderResult result) {
dialog.dismiss();
mFilesAdapter.setFiles(result.getEntries());
}
@Override
public void onError(Exception e) {
dialog.dismiss();
Log.e(TAG, "Failed to list folder.", e);
Toast.makeText(FilesActivity.this,
"An error has occurred",
Toast.LENGTH_SHORT)
.show();
}
}).execute(mPath);
}
private void download(final ArrayList<SongItem> listAll, final LrcJaeger activity) {
if (listAll.size() > 0) {
final ProgressDialog progressDialog = new ProgressDialog(activity);
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressDialog.setTitle(activity.getString(R.string.title_downloading));
progressDialog.setProgress(0);
progressDialog.setMax(listAll.size());
progressDialog.show();
activity.mTask = new BulkDownloadTask(new BulkDownloadTask.EventListener() {
@Override
public void onFinish(int downloaded) {
progressDialog.dismiss();
sendEmptyMessage(MSG_UPDATE_LRC_ICON_ALL);
String text = String.format(activity.getString(R.string.toast_lrc_downloaded),
downloaded, listAll.size());
Toast.makeText(activity, text, Toast.LENGTH_SHORT).show();
}
@Override
public void onProgressUpdate(int progress) {
progressDialog.setProgress(progress);
}
});
activity.mTask.execute(listAll.toArray(new SongItem[1]));
}
}
private void createProgressDialog() {
mProgressDialog = new ProgressDialog(MainActivity.this);
mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
mProgressDialog.setTitle(getString(R.string.updating));
mProgressDialog.setIndeterminate(false);
mProgressDialog.setMax(100);
mProgressDialog.setCancelable(false);
mProgressDialog.setCanceledOnTouchOutside(false);
mProgressDialog.show();
}
@Override
protected void onPreExecute() {
super.onPreExecute();
Log.d("MainActivity", "About to load recipes from file - starting progress spinner");
progress = new ProgressDialog(MainActivity.this);
progress.setMessage("Loading...");
progress.setIndeterminate(false);
progress.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progress.setCancelable(false);
progress.show();
}
protected void onPreExecute() {
super.onPreExecute();
progressDialog = new ProgressDialog(context);
progressDialog.setMessage("Downloading video...");
progressDialog.setProgressStyle(1);
progressDialog.setCanceledOnTouchOutside(false);
progressDialog.setMax(100);
progressDialog.show();
//Toast.makeText(getActivity(), "Downloading video....", Toast.LENGTH_SHORT).show();
}
@Override
protected void onPreExecute() {
super.onPreExecute();
progress = new ProgressDialog(this.context);
progress.setMessage(this.message);
progress.setIndeterminate(false);
progress.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progress.setCancelable(false);
progress.show();
}
/**
* Called when the OK button is clicked in the dialog window.
*/
@Override
public final void onPositive() {
// Get the user data.
String nick = this.dialogTxtNick.getText().toString().trim();
String adoptID = this.dialogTxtShare.getText().toString().trim();
Log.v("User initiated adoption with nick=%s, id=%s", nick, adoptID); //NON-NLS
// Create a processing dialog, since we are interacting with an external server, which can
// take some time.
final ProgressDialog progress = new ProgressDialog(this.ctx);
progress.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progress.setTitle(R.string.progress_adopt_title);
progress.setMessage(String.format(this.ctx.getString(R.string.progress_adopt_body), nick));
progress.setIndeterminate(true);
progress.setCancelable(false);
progress.show();
// Send the HTTP request to try and adopt the share.
new AdoptSharePacket(this.ctx, this.share, adoptID, nick) {
@Override
public void onSuccessfulAdoption(String nickname) {
Log.i("Adoption was successful for nick=%s", nickname); //NON-NLS
progress.dismiss();
AdoptDialogBuilder.this.onSuccess(nickname);
}
@Override
protected void onFailure(Exception ex) {
Log.w("Adoption failed", ex); //NON-NLS
progress.dismiss();
AdoptDialogBuilder.this.onFailure(ex);
}
}.send();
}
@Override
protected void onPreExecute()
{
super.onPreExecute();
if ( mFileLoadListener!= null ){
mFileLoadListener.onPreFileLoad();
}
mProgressDialog = new ProgressDialog(mActivity);
// mProgressDialog.setTitle(R.string.spinner_message);
mProgressDialog.setMessage(mActivity.getString(R.string.spinner_message));
mProgressDialog.setIndeterminate(true);
mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
mProgressDialog.setCancelable(false);
mProgressDialog.show();
}
private void showDialog(String message) {
progressDialog = new ProgressDialog(this);
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progressDialog.setCanceledOnTouchOutside(false);
progressDialog.setMessage(message);
progressDialog.show();
}
@Override
protected void onPreExecute() {
super.onPreExecute();
is_finishing = isFinishing();
mProgressDialog = new ProgressDialog(UpdateCheckActivity.this);
mProgressDialog.setMessage(getStringWithLocale(R.string.download_progress));
mProgressDialog.setIndeterminate(true);
mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
mProgressDialog.setCancelable(false);
mProgressDialog.setProgressNumberFormat("%1d file(s)");
if (!is_finishing) {
mProgressDialog.show();
}
}
protected void onPreExecute() {
progressDialog = new ProgressDialog(activity);
progressDialog.setMessage(activity.getString(R.string.deleting));
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressDialog.setIndeterminate(true);
progressDialog.setProgressNumberFormat(null);
progressDialog.setProgressPercentFormat(null);
progressDialog.setCancelable(false);
progressDialog.show();
}
/**
* 弹出下载对话框
*/
public void showDownloadDialog() {
mDownloadDialog = new ProgressDialog(mContext);
mDownloadDialog.setIcon(R.mipmap.ic_launcher);
mDownloadDialog.setTitle("版本更新");
mDownloadDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
mDownloadDialog.setMessage("正在玩命下载中......");
mDownloadDialog.getWindow().setGravity(Gravity.CENTER);
mDownloadDialog.setMax(100);
mDownloadDialog.show();
}
public BitmapDialogCallback(Activity activity) {
super(1000, 1000);
dialog = new ProgressDialog(activity);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setCanceledOnTouchOutside(false);
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
dialog.setMessage("请求网络中...");
}
private void getData(final boolean needDialog) {
final ProgressDialog dialog = new ProgressDialog(BankCardActivity.this);
if (needDialog) {
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
dialog.setMessage("正在加载...");
dialog.show();
}
Map<String, String> map = new HashMap<String, String>();
map.put("hxid", MYApplication.getInstance().getUserName());
LoadDataFromServer task = new LoadDataFromServer(BankCardActivity.this,
Constant.URL_CARDS, map);
task.getData(new DataCallBack() {
@Override
public void onDataCallBack(JSONObject data) {
if (needDialog && dialog.isShowing()) {
dialog.dismiss();
}
if (data == null) {
Toast.makeText(getApplicationContext(), "访问服务器错误,更新失敗...",
Toast.LENGTH_SHORT).show();
return;
}
int code = data.getInteger("code");
if (code == 1) {
datas = data.getJSONArray("data");
adapter = new MyAdapter(BankCardActivity.this, datas);
listView.setAdapter(adapter);
ACache.get(getApplicationContext()).put(Constant.CARDLIST,
datas);
} else {
Toast.makeText(getApplicationContext(), "更新失敗...",
Toast.LENGTH_SHORT).show();
}
}
});
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
prefsFile.setReadable(true, false);
mPrefs = getSharedPreferences(Common.PREFS, Context.MODE_WORLD_READABLE);
languages = new ArrayList<>();
LocaleList localeList = new LocaleList(getApplicationContext(), "");
languages.addAll(localeList.getDescriptionList());
languages.remove(0);
checkItems = new boolean[languages.size()];
String[] langs = mPrefs.getString("languages", "").split(",");
for (int i = 0; i < langs.length; i++) {
int index = languages.indexOf(localeList.getDescriptionList().get(localeList.getLocalePos(langs[i])));
if (index > -1) {
checkItems[index] = true;
}
}
tmpCheckItems = Arrays.copyOf(checkItems, checkItems.length);
mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mRecyclerView.setItemAnimator(new DefaultItemAnimator());
mRecyclerView.addItemDecoration(new DividerDecoration(this));
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mRecyclerView.scrollToPosition(0);
}
});
pm = getPackageManager();
List<PackageInfo> packages = pm.getInstalledPackages(0);
mProgressDialog = new ProgressDialog(this);
mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
mProgressDialog.setMax(packages.size());
mProgressDialog.setMessage(getString(R.string.loading_apps));
mProgressDialog.setCancelable(false);
new GetAppsTask().execute(packages);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mProgressDialog = new ProgressDialog(this);
mProgressDialog.setIndeterminate(true);
mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
EasyTracker.getInstance().setContext(this);
}