Progress Bar Tutorial For Android

Purpose of Progress Bar

Progress Bar is used when app required some progressing behind or require some procesing which take time to show the user app is busy and will take time. Here is the source code to show progerss bar on android.


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android=""
	android:background="@drawable/splash" android:layout_height="fill_parent"
	<LinearLayout android:layout_alignParentBottom="true"
		android:layout_centerHorizontal="true" android:layout_marginBottom="58px"
		android:layout_height="45px" android:layout_width="200px"
		android:id="@+id/lin_progress_bar" android:visibility="invisible">
		<ProgressBar android:id="@+id/ProgressBar01"
			android:layout_width="wrap_content" android:layout_height="wrap_content"></ProgressBar>
		<TextView android:id="@+id/TextView01" android:layout_height="fill_parent"
			android:layout_width="fill_parent" android:gravity="center_vertical"
			android:textStyle="bold" android:text="Loading..."
			android:layout_marginLeft="10px" android:textSize="23px"

Progress Bar is used under the linear layout tag to simply hide and show the layout as required.

public class Splash extends Activity {

	private LinearLayout linProgressBar;
	private final Handler uiHandler=new Handler();
	private boolean isUpdateRequired=false;

	protected void onCreate(Bundle savedInstanceState) {


	public void basicInitializations(){

		linProgressBar = (LinearLayout) findViewById(;

			new Thread(){
				public void run() {
					initializeApp(); new Runnable(){
						public void run() {
								startActivity( new Intent(WMXSplash.this, WMXLogin.class) );
					} );
				public void initializeApp(){
					// Initialize application data here
		}catch (Exception e) {}

Thread starts when processing starts and when processing completes dialog box dismissed and layout gone.

Loading Progress Bar

see the blog.

This entry was posted in Android, Tutorials and tagged , , , , . Bookmark the permalink.

One Response to Progress Bar Tutorial For Android

  1. sales tips says:

    It’s so lucky for me to find your!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s