Android进度条不显示
我使用firebase发布某个日期,我需要在上传数据时使用进度对话框指示用户。我导入进度对话框,我需要在上传前显示它,并在上传后关闭它。但是,“进度”对话框根本不会出现 谁能告诉我哪里出错了,谢谢Android进度条不显示,android,firebase,firebase-realtime-database,Android,Firebase,Firebase Realtime Database,我使用firebase发布某个日期,我需要在上传数据时使用进度对话框指示用户。我导入进度对话框,我需要在上传前显示它,并在上传后关闭它。但是,“进度”对话框根本不会出现 谁能告诉我哪里出错了,谢谢 private ProgressDialog progressDialog; progressDialog = new ProgressDialog(this); public void postHelp() { progressDialog.setMessage("Posting yo
private ProgressDialog progressDialog;
progressDialog = new ProgressDialog(this);
public void postHelp() {
progressDialog.setMessage("Posting your request...");
progressDialog.show();
final String postTitle = title.getText().toString().trim();
final String postDesc = desc.getText().toString().trim();
final String postAddress = address.getText().toString().trim();
final String postPhone = phone.getText().toString().trim();
//check input fields
if (!TextUtils.isEmpty(postTitle) && !TextUtils.isEmpty(postDesc)
&& !TextUtils.isEmpty(postAddress) && !TextUtils.isEmpty(postPhone)) {
final DatabaseReference newRequest = database.push();
mDatabaseUser.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
newRequest.child("Title").setValue(postTitle);
newRequest.child("Desc").setValue(postDesc);
newRequest.child("Address").setValue(postAddress);
newRequest.child("Phone").setValue(postPhone);
progressDialog.dismiss();
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
Intent main = (new Intent(AddPostActivity.this,MainActivity.class));
main.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(main);
}
}
调用对话框生成器,如下所示:
AlertDialog.Builder diaog = new AlertDialog.Builder(this,android.R.style.Theme_DeviceDefault_Dialog)
.setTitle(title)
.setMessage(message)
.setPositiveButton(okBtn, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
})
.setCancelable(false)
;
然后
@MarcGV您可以在android o中找到它。Opost完整的代码…您在活动中在哪里使用
这个?
dialog.show();
dialog.dismiss();