What is Progress Dialog
A dialog showing a progress indicator and an
optional text message or view. Only a text message or a view can be used at the
same time.
The
dialog can be made cancelable on back key press.
The
progress range is 0..10000.
Progress dialogs
are very commonly used components in all User Interfaces, when you want to
display the progress of a task that is taking up a lot of time, for example a
file or an Image download.
activity_main.xml
------------------
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Progress Dialog"
android:id="@+id/button"
android:layout_gravity="center_horizontal" />
</LinearLayout>
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Progress Dialog"
android:id="@+id/button"
android:layout_gravity="center_horizontal" />
</LinearLayout>
MainActivity.Java
------------------
package com.anil.android.dialog; import android.app.ProgressDialog; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; public class MainActivity extends AppCompatActivity { Button pdbtn; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); pdbtn=(Button)findViewById(R.id.button); pdbtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ProgressDialog pd=new ProgressDialog(MainActivity.this); pd.setTitle("Downloading"); pd.setIcon(R.mipmap.ic_launcher); pd.setMessage("please wait loading"); pd.show(); } }); } }
Output is:
-----------------
No comments:
Post a Comment