showing progress bar in alert dialog
android
Solution
It might be easier to use this
ProgressDialog dialog = ProgressDialog.show(MyActivity.this, "",
"Loading. Please wait...", true);
You can read more about progress dialogs here
To cancel would be
dialog.dismiss();
This class was deprecated in API level 26. ProgressDialog is a modal dialog, which prevents the user from interacting with the app. Instead of using this class, you should use a progress indicator like ProgressBar, which can be embedded in your app's UI. Alternatively, you can use a notification to inform the user of the task's progress.For more details Click Here
Problem
I have an alert dialog box in my application for login authentication. While sending the request i want to show a progress bar and want to dismiss if the response is success.please help me if anyone knows.Iam using the below code: ``` final AlertDialog.Builder alert = new AlertDialog.Builder(this); LinearLayout login = new LinearLayout(this); TextView tvUserName = new TextView(this); TextView tvPassword = new TextView(this); TextView tvURL = new TextView(this); final EditText etUserName = new EditText(this); final EditText etPassword = new EditText(this); final EditText etURL = new EditText(this); login.setOrientation(1); // 1 is for vertical orientation tvUserName.setText(getResources().getString(R.string.username)); tvPassword.setText(getResources().getString(R.string.password)); tvURL.setText("SiteURL"); login.addView(tvURL); login.addView(etURL); login.addView(tvUserName); login.addView(etUserName); login.addView(tvPassword); etPassword.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); login.addView(etPassword); alert.setView(login); alert.setTitle(getResources().getString(R.string.login)); alert.setCancelable(true); alert.setPositiveButton(getResources().getString(R.string.login), new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, int whichButton) { strhwdXml = etURL.getText().toString(); strUserName = etUserName.getText().toString(); XmlUtil.username = strUserName; strPassword = etPassword.getText().toString(); if ((strUserName.length() == 0) && (strPassword.length() == 0) && (strhwdXml.length() == 0)) { Toast.makeText( getBaseContext(), getResources().getString( R.string.userPassword), Toast.LENGTH_SHORT).show(); onStart(); } else { final SharedPreferences prefs = PreferenceManager .getDefaultSharedPreferences(getApplicationContext()); SharedPreferences.Editor prefsEditor = prefs .edit(); try { StringBuffer inStreamBuf = new StringBuffer(); inStreamBuf = XmlUtil .getLoginAuthResponse(strUserName, strPassword, strhwdXml); strXmlResponse = inStreamBuf.toString(); Log.e("Response:", strXmlResponse); String parsedXML = ParseResponse(strXmlResponse); if (parsedXML .equalsIgnoreCase(getResources() .getString(R.string.success))) { } ```