0% found this document useful (0 votes)
314 views

Practical 13 PDF

This document describes a program to implement a circular progress bar in Android. The program displays a progress bar using a ProgressDialog and updates the progress at regular intervals using a Timer and TimerTask. The activity_main.xml layout contains a button and MainActivity.java handles the button click to show the progress dialog, set its properties like style, max value, and updates the progress from 0-100 over time.

Uploaded by

Ajinkya Patil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
314 views

Practical 13 PDF

This document describes a program to implement a circular progress bar in Android. The program displays a progress bar using a ProgressDialog and updates the progress at regular intervals using a Timer and TimerTask. The activity_main.xml layout contains a button and MainActivity.java handles the button click to show the progress dialog, set its properties like style, max value, and updates the progress from 0-100 over time.

Uploaded by

Ajinkya Patil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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