Why the background of ProgressDialog doesn’t set to the transparent?

create custom MyTheme in values\styles.xml <style name=”MyTheme” parent=”android:Theme.Holo.Dialog”> <item name=”android:alertDialogStyle”>@style/CustomAlertDialogStyle</item> <item name=”android:windowBackground”>@android:color/transparent</item> <item name=”android:textColorPrimary”>#FFFFFF</item> <item name=”android:backgroundDimEnabled”>false</item> <item name=”android:textColor”>#FFFFFF</item> <item name=”android:textStyle”>normal</item> <item name=”android:textSize”>12sp</item> </style> And also add this CustomAlertDialogStyle in values\styles.xml <style name=”CustomAlertDialogStyle”> <item name=”android:bottomBright”>@android:color/transparent</item> <item name=”android:bottomDark”>@android:color/transparent</item> <item name=”android:bottomMedium”>@android:color/transparent</item> <item name=”android:centerBright”>@android:color/transparent</item> <item name=”android:centerDark”>@android:color/transparent</item> <item name=”android:centerMedium”>@android:color/transparent</item> <item name=”android:fullBright”>@android:color/transparent</item> <item name=”android:fullDark”>@android:color/transparent</item> <item name=”android:topBright”>@android:color/transparent</item> <item name=”android:topDark”>@android:color/transparent</item> </style> And set … Read more

Prevent ProgressDialog from being dismissed when I click the search button (Android)

This works (notice I put it on the dialog builder): .setOnKeyListener(new DialogInterface.OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_SEARCH && event.getRepeatCount() == 0) { return true; // Pretend we processed it } return false; // Any other keys are still processed as normal } }) Maybe it’s … Read more

Add a Progress Bar in WebView

I have added few lines in your code and now its working fine with progress bar. getWindow().requestFeature(Window.FEATURE_PROGRESS); setContentView(R.layout.main ); // Makes Progress bar Visible getWindow().setFeatureInt( Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON); webview = (WebView) findViewById(R.id.webview); webview.setWebChromeClient(new WebChromeClient() { public void onProgressChanged(WebView view, int progress) { //Make the bar disappear after URL is loaded, and changes string to Loading… setTitle(“Loading…”); … Read more

ProgressDialog is deprecated.What is the alternate one to use?

Yes, in API level 26 it’s deprecated. Instead, you can use progressBar. To create it programmatically: First get a reference to the root layout RelativeLayout layout = findViewById(R.id.display); //specify here Root layout Id or RelativeLayout layout = findViewById(this); Then add the progress bar progressBar = new ProgressBar(youractivity.this, null, android.R.attr.progressBarStyleLarge); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(100, 100); … Read more

Can’t create handler inside thread that has not called Looper.prepare() inside AsyncTask for ProgressDialog

The method show() must be called from the User-Interface (UI) thread, while doInBackground() runs on different thread which is the main reason why AsyncTask was designed. You have to call show() either in onProgressUpdate() or in onPostExecute(). For example: class ExampleTask extends AsyncTask<String, String, String> { // Your onPreExecute method. @Override protected String doInBackground(String… params) … Read more

How to display progress dialog before starting an activity in Android?

You should load data in an AsyncTask and update your interface when the data finishes loading. You could even start a new activity in your AsyncTask’s onPostExecute() method. More specifically, you will need a new class that extends AsyncTask: public class MyTask extends AsyncTask<Void, Void, Void> { public MyTask(ProgressDialog progress) { this.progress = progress; } … Read more