Friday, 19 October 2012

ANDROID - Progress Dialog

Demo:



1)main.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/LinearLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#9932CC"
    android:orientation="vertical" >

    <Button
        android:id="@+id/buttonProgressDialog"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="90dp"
        android:text="Show ProgressDialog"
        android:textSize="20dp" />

</LinearLayout>

2)Activity:

package com.venky.progressdialogdemo;

import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class ProgressDialogDemoActivity extends Activity {
      /** Called when the activity is first created. */

      Button buttonProgressDialog;

      @Override
      public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);

            // call the references
            buttonProgressDialog = (Button) findViewById(R.id.buttonProgressDialog);

            // set the Listener for Button
            buttonProgressDialog.setOnClickListener(new OnClickListener() {

                  public void onClick(View v) {
                        // TODO Auto-generated method stub

                        // Create ProgressDialog
                        ProgressDialog progressDialog = new ProgressDialog(
                                    ProgressDialogDemoActivity.this);

                        // set Icon
                        progressDialog.setIcon(R.drawable.ic_launcher);

                        // set Title
                        progressDialog.setTitle("ProgressDialog");

                        // set Message
                        progressDialog.setMessage("ProgressDialog is Loading ....");

                        // show ProgressDialog
                        progressDialog.show();
                  }
            });

      }
}


3)Download this Project Click Here
  

1 comment: