Created
September 19, 2019 09:40
-
-
Save sandeepyohans/bf95616054c27ef1d8c609de32f08bb9 to your computer and use it in GitHub Desktop.
Utility method to display AlertDialog with ProgressBar in Android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public AlertDialog.Builder getDialogProgressBar() { | |
AlertDialog.Builder builder = new AlertDialog.Builder(Objects.requireNonNull(getContext())); | |
builder.setTitle("Loading..."); | |
builder.setCancelable(false); | |
final ProgressBar progressBar = new ProgressBar(getContext()); | |
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( | |
LinearLayout.LayoutParams.WRAP_CONTENT, | |
LinearLayout.LayoutParams.WRAP_CONTENT); | |
progressBar.setLayoutParams(lp); | |
builder.setView(progressBar); | |
// builder.setPositiveButton("OK", | |
// (dialogInterface, i) -> Toast.makeText(getApplicationContext(), | |
// "Text entered is " + input.getText().toString(), | |
// Toast.LENGTH_SHORT).show()); | |
return builder; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment