How to realize the function of progress bar in the form of a dialog box in Android
This article mainly introduces the Android how to achieve a dialog form of the progress bar function related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe that everyone in this Android how to achieve a dialog form of the progress bar function article will have a harvest, let's take a look.
The MainActivity code is as follows:
Package com.example.myapplication;import android.app.ProgressDialog;import android.content.DialogInterface;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.view.View;import android.widget.Button;import android.widget.Toast;public class MainActivity extends AppCompatActivity implements View.OnClickListener {ProgressDialog prodialog; Button show; @ Override protected void onCreate (Bundle savedInstanceState) {super.onCreate (savedInstanceState); setContentView (R.layout.activity_main); show = (Button) findViewById (R.id.show) Show.setOnClickListener (this);} @ Override public void onClick (View view) {prodialog = new ProgressDialog (MainActivity.this); prodialog.setProgressStyle (ProgressDialog.STYLE_HORIZONTAL); prodialog.setTitle (""); prodialog.setMessage ("jb51"); prodialog.setIcon (R.mipmap.ic_launcher); / / Design progress bar properties prodialog.setMax (100); prodialog.incrementProgressBy (50); / / clearly show progress prodialog.setIndeterminate (false) Prodialog.setButton (DialogInterface.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener () {@ Override public void onClick (DialogInterface dialogInterface, int I) {Toast.makeText (MainActivity.this, "hello", Toast.LENGTH_LONG). Show ();}}); prodialog.setCancelable (true); prodialog.show ();}}
Layout file:
This is the end of the article on "how to implement the progress bar function in the form of a dialog box in Android". Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "how to achieve the function of progress bar in the form of a dialog box in Android". If you want to learn more knowledge, you are welcome to follow the industry information channel.