Circular progress bar-style Dialog (window)
public void showPD(View view) throws InterruptedException {
final ProgressDialog dialog = ProgressDialog.show(this,"Data loading","Data loading...");
new Thread(new Runnable() {
@Override
public void run() {
for (int i = 0;i<20 ;i++)
{
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
dialog.dismiss();
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(DialogActivity.this,"Loading complete",Toast .LENGTH_SHORT).show();
}
});
}
}).start();
}
Horizontal progress bar-style Dialog (window)
public void showPD2(View view)
{
final ProgressDialog pd = new ProgressDialog(this);
pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
pd.show();
new Thread(new Runnable() {
@Override
public void run() {
pd.setMax(20);
for(int i =0;i<20 ;i++)
{
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
pd.setProgress(pd.getProgress()+1);
}
pd.dismiss();
}
}).start();
}
A show(ProgressDialog.show) A new (new ProgressDialog(this))
< /p>
Circular progress bar Dialog (window)
public void showPD(View view) throws InterruptedException {
final ProgressDialog dialog = ProgressDialog.show(this,"Data loading","Data loading...");
new Thread(new Runnable() {
@Override
public void run() {
for (int i = 0;i<20 ;i++)
{
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
dialog.dismiss();
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(DialogActivity.this,"Loading complete",Toast .LENGTH_SHORT).show();
}
});
}
}).start();
}
Horizontal progress bar-style Dialog (window)
public void showPD2(View view)
{
final ProgressDialog pd = new ProgressDialog(this);
pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
pd.show();
new Thread(new Runnable() {
@Override
public void run() {
pd.setMax(20);
for(int i =0;i<20 ;i++)
{
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
pd.setProgress(pd.getProgress()+1);
}
pd.dismiss();
}
}).start();
}
A show(ProgressDialog.show) A new (new ProgressDialog(this))
< p>