0% found this document useful (0 votes)
420 views7 pages

Practical No 13

hi am study in computer

Uploaded by

sayedfaizan558
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)
420 views7 pages

Practical No 13

hi am study in computer

Uploaded by

sayedfaizan558
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/ 7

Mobile Application Development (22617) Practical No.

13

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

I. Practical Significance
Progress bars are used to show progress of a task. For example, when you are uploading or
downloading something from the internet, it is better to show the progress of
download/upload to the user. In android there is a class called Progress Dialog that allows you
to create progress bar.

II. Relevant Program Outcomes (POs)


PO 2. Discipline knowledge
PO 3. Experiments and practice
PO 4. Engineering tools

III. Competency and Skills


“Create simple Android applications.”
This practical is expected to develop the following skills
1. Able to develop an application using Progress bar.

IV. Relevant Course Outcome(s)


1. Develop rich user Interfaces by using layouts and controls.
2. Use User Interface components for android application development.

V. Practical Outcomes (PrOs)


Develop a program to implement Progress Bar

VI. Relevant Affective Domain Related Outcome(s)


1. Work collaboratively in team
2. Follow ethical practices

VII. Minimum Theoretical Background


A user interface element that indicates the progress of an operation. For a visual overview of
the difference between determinate and indeterminate progress modes, see Progress &
activity. Display progress bars to a user in a non-interruptive way. Progress bar supports two
modes to represent progress: determinate and indeterminate.
Indeterminate Progress
Use indeterminate mode for the progress bar when you do not know how long an
operation will take. Indeterminate mode is the default for progress bar and shows
a cyclic animation without a specific amount of progress indicated.
Determinate Progress
Use determinate mode for the progress bar when you want to show that a specific quantity
of progress has occurred. For example, the percent remaining of a file being retrieved, the
amount records in a batch written to database, or the percent remaining of an audio file that
is playing.
Progress Dialog is a class that allows you to create progress bar. In order to do this,
you need to instantiate an object of this class. Its syntax is. ProgressDialog
dialog=new ProgressDialog(this);

Maharashtra State Board of Technical Education 1


Mobile Application Development (22617) Practical No. 13

VIII. Resources required (Additional)

Sr. No. Instrument /Object Specification Quantity Remarks

Android enabled 2 GB RAM 1 Data cable is


smartphone / Android mandatory for
1
version supporting emulators
emulator

IX. Practical related Questions


Note: Below given are few sample questions for reference. Teachers must design more
such questions to ensure the achievement of identified CO.
1. State different methods to update the percentage of progress displayed.
2. Write an xml tag for the determinate progress bar.
3. List different progress bar styles provided by the system.

(Space for answers)

1.
You can update the percentage of progress displayed by using the setProgress(int) method, or
by calling incrementProgressBy(int) to increase the current progress completed by a specified
amount.

2.
<ProgressBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:indeterminate="true"/>

3.
Progress bar styles provided by the system include:
 Widget.ProgressBar.Horizontal
 Widget.ProgressBar.Small
 Widget.ProgressBar.Large
 Widget.ProgressBar.Inverse
 Widget.ProgressBar.Small.Inverse

Maharashtra State Board of Technical Education 2


Mobile Application Development (22617) Practical No. 13

 Widget.ProgressBar.Large.Inverse

X. Exercise
Note: Below given are few sample questions for reference. Teachers must design different
questions for practice.
(Use blank space for answers or attach more pages if needed)
1. Write a program to display circular progress bar.
2. Write a program to show the following output.

(Space for answers)


1.
//MainActivity.java
package com.jamiapolytechnic.experiment132;

import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}

//=====================================================================
//activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

Maharashtra State Board of Technical Education 3


Mobile Application Development (22617) Practical No. 13

android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<ProgressBar
android:id="@+id/simpleProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Circular Progressbar" />
</LinearLayout>

=====================================================================
2.
//MainActivity.java
package com.jamiapolytechnic.experiment131;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {


private ProgressBar pgsBar;
private int i = 0;
private TextView txtView1, txtView2;
private Handler hdlr = new Handler();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
pgsBar = (ProgressBar) findViewById(R.id.pBar);
txtView1 = (TextView) findViewById(R.id.t1View);
txtView2 = (TextView) findViewById(R.id.t2View);
Button btn = (Button)findViewById(R.id.btnShow);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
i = pgsBar.getProgress();
new Thread(new Runnable() {
public void run() {
while (i < 100) {
i += 1;

Maharashtra State Board of Technical Education 4


Mobile Application Development (22617) Practical No. 13

// Update the progress bar and display the current value in text view
hdlr.post(new Runnable() {
public void run() {
pgsBar.setProgress(i);
txtView1.setText(i+"%");
txtView2.setText(i+"/"+pgsBar.getMax());
}
});
try {
// Sleep for 100 milliseconds to show the progress slowly.
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}).start();
}
});
}
}

//=====================================================================
//activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<TextView
android:id="@+id/txt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="140dp"
android:layout_marginTop="200dp"
android:text="File downloading ..." />
<ProgressBar
android:id="@+id/pBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/txt1"
android:layout_marginLeft="100dp"
android:minHeight="50dp"
android:minWidth="200dp"
android:max="100"
android:indeterminate="false"
android:progress="0" />

Maharashtra State Board of Technical Education 5


Mobile Application Development (22617) Practical No. 13

<TextView
android:id="@+id/t1View"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/pBar"
android:layout_below="@+id/pBar" />
<TextView
android:id="@+id/t2View"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/pBar"
android:layout_below="@+id/pBar" />
/>
<Button
android:id="@+id/btnShow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="130dp"
android:layout_marginTop="20dp"
android:text="Start Progress"
android:layout_below="@+id/t1View"/>
</RelativeLayout>

Maharashtra State Board of Technical Education 6


Mobile Application Development (22617) Practical No. 13

XI. References / Suggestions for further Reading


1. https://www.tutorialspoint.com/android
2. https://stuff.mit.edu
3. https://www.tutorialspoint.com/android/android_advanced_tutorial.pdf
4. https://developer.android.com

XII. Assessment Scheme

Performance indicators Weightage

Process related (10 Marks) 30%

1. Logic Formation 10%


2. Debugging ability 15%
3. Follow ethical practices 5%
Product related (15 Marks) 70%

4. Interactive GUI 20%


5. Answer to Practical related questions 20%
6. Expected Output 20%
7. Timely Submission 10%
Total (25 Marks) 100%

List of students/Team Members


1
2
3
4

Dated signature of
Marks Obtained
Teacher
Process Product Total
Related(10) Related(15) (25)

Maharashtra State Board of Technical Education 7

You might also like