You are on page 1of 2

Practical No. 13 : Develop a program to implement Progress Bar.

Name: Ajinkya P. Patil Class: TYCM-II Roll No.: 39

1. Write a program to display circular progress bar.

activity_main.xml Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/a <Button
pk/res/android" android:id="@+id/b1"
android:layout_width="wrap_content"
xmlns:app="http://schemas.android.com/apk/r
es-auto" android:layout_height="wrap_content"
android:gravity="center"
xmlns:tools="http://schemas.android.com/too android:layout_weight="1"
ls" android:text="Button" />
android:layout_width="match_parent" </LinearLayout>
android:layout_height="match_parent"
tools:context=".MainActivity">

MainActivity.java Code:

package com.example.practical_11; pd.setProgressStyle(ProgressDialog.STYLE_HO


package com.example.pr13_2; RIZONTAL);
pd.setMax(100);
import pd.setIndeterminate(false);
androidx.appcompat.app.AppCompatActivity; pd.setTitle("Android
Developers");
import android.app.ProgressDialog; pd.setMessage("Dowloading
import android.os.Bundle; File");
import android.view.View; pd.show();
import android.widget.Button; Timer t = new Timer();
TimerTask tsk = new
import java.util.Timer; TimerTask() {
import java.util.TimerTask; @Override
public void run() {
public class MainActivity extends couter++;
AppCompatActivity {
pd.setProgress(couter);
Button b1; if(couter == 100)
ProgressDialog pd; {
int couter = 0 , max; t.cancel();
}
@Override }
protected void onCreate(Bundle };
savedInstanceState) { t.schedule(tsk,0,100);
super.onCreate(savedInstanceState);
}
setContentView(R.layout.activity_main); });
b1 = findViewById(R.id.b1);
b1.setOnClickListener(new
View.OnClickListener() {
@Override
public void onClick(View v) { }
pd = new
ProgressDialog(MainActivity.this); }
Output:

You might also like