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="[Link]
xmlns:tools="[Link]
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 [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
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)
{
[Link](savedInstanceState);
setContentView([Link].activity_main);
progressBar = (ProgressBar) findViewById([Link]);
textView = (TextView) findViewById([Link]);
// 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
[Link](new Runnable()
{
public void run()
{
[Link](progressStatus);
[Link](progressStatus+"/"+[Link]());
}
});
try
{
// Sleep for 200 milliseconds.
[Link](200);
}
catch (InterruptedException e)
{
[Link]();
}
}
}
});
start();
}
}
Output :-
2). Write a program to show the following output.
Code :-
XML CODE
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="[Link] m/apk/res/android"
xmlns:app="[Link]
xmlns:tools="[Link]
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 [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends AppCompatActivity
{
Button btnDownloadFile;
ProgressDialog progressDialog;
@Override
protected void onCreate(Bundle savedInstanceState)
{
[Link](savedInstanceState);
setContentView([Link].activity_main);
btnDownloadFile = findViewById([Link]);
[Link](new [Link]())
{
@Override
public void onClick(View v)
{
progressDialog = newProgressDialog ([Link]);
[Link](ProgressDialog.STYLE_HORIZONTAL);
[Link]("File Downloading");
[Link](100);
Thread t = new Thread(new Runnable()
{
@Override
public void run() { int progress = 0;
while (progress <=100)
{
try
{
[Link](progress);
}
progress++;
[Link](200);
}
catch (Exception ex)
{
}
}
[Link]();
}
});
[Link]();
[Link]();
}
});
}
}
Output :-