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

Practical 13

The document contains two exercises related to mobile application development, focusing on creating a circular progress bar and a file download button with a progress dialog. The first exercise includes XML and Java code to implement a progress bar that updates its status in real-time. The second exercise provides code for a button that, when clicked, shows a progress dialog indicating the progress of a file download operation.

Uploaded by

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

Practical 13

The document contains two exercises related to mobile application development, focusing on creating a circular progress bar and a file download button with a progress dialog. The first exercise includes XML and Java code to implement a progress bar that updates its status in real-time. The second exercise provides code for a button that, when clicked, shows a progress dialog indicating the progress of a file download operation.

Uploaded by

sainathkorpakwad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Subject :- Mobile Application Developmen Subject Code :- 22617

Name :- Shivam Sainath Korpakwad Batch :- CO 6 IA Roll No. 24

Exercise :-

1). Write a program to display Circular progress bar.


Code :-
<RelativeLayout xmlns:android="https://schemas.android.com/apk/res/android"
xmlns:tools="https://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="23dp"
android:layout_marginTop="20dp"
android:indeterminate="false"
android:max="100"
android:minHeight="50dp"
android:minWidth="200dp"
android:progress="1" />
<ProgressBar
android:id="@+id/progressBar_cyclic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minHeight="50dp"
android:minWidth="50dp"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/progressBar"
android:layout_below="@+id/progressBar"/>
</RelativeLayout>
package com.journaldev.progressbar;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ProgressBar;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity
{
private ProgressBar progressBar;
private int progressStatus = 0;
private TextView textView;
private Handler handler = new Handler();
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
progressBar = (ProgressBar) findViewById(R.id.progressBar);
textView = (TextView) findViewById(R.id.textView);
// Start long running operation in a background thread
new Thread(new Runnable()
{
public void run()
{
while (progressStatus < 100) {
progressStatus += 1;
// Update the progress bar and display the //current value in the text view
handler.post(new Runnable()
{
public void run()
{
progressBar.setProgress(progressStatus);
textView.setText(progressStatus+"/"+progressBar.getMax());
}
});
try
{
// Sleep for 200 milliseconds.
Thread.sleep(200);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
}
}
});
start();
}
}

Output :-
2). Write a program to show the following output.

Code :-

XML CODE
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.co m/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<Button
android:id="@+id/btnDownloadFile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Download File"
android:layout_centerInParent="true"
/>
</RelativeLayout>
JAVA CODE
package com.example.progrogress;
import androidx.appcompat.app.AppCompatActivity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity
{
Button btnDownloadFile;
ProgressDialog progressDialog;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btnDownloadFile = findViewById(R.id.btnDownloadFile);
btnDownloadFile.setOnClickListener(new View.OnClickListener())
{
@Override
public void onClick(View v)
{
progressDialog = newProgressDialog (MainActivity.this);
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressDialog.setTitle("File Downloading");
progressDialog.setProgress(100);
Thread t = new Thread(new Runnable()
{
@Override
public void run() { int progress = 0;
while (progress <=100)
{
try
{
progressDialog.setProgress(progress);
}
progress++;
Thread.sleep(200);
}
catch (Exception ex)
{
}
}
progressDialog.dismiss();
}
});
t.start();
progressDialog.show();
}
});
}
}
Output :-

You might also like