Wednesday, December 22, 2010

Android Customize Dialog

Android-Customize Dialog window.


Full Source Code:
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/LinearLayout01"
    android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"
    android:background="@drawable/bg_android" android:orientation="vertical"
    android:gravity="center" android:layout_width="200dip">
    <TextView android:id="@+id/TextView01"
   
    android:layout_height="wrap_content"
        android:textColor="#ffa800" android:textStyle="bold"
       
        android:layout_width="wrap_content" android:text=" iamvijayakumar.blogs.com "></TextView>
    <TextView android:id="@+id/TextView02" android:layout_height="wrap_content"
        android:textColor="#FFFFFF" android:layout_width="wrap_content"
        android:textStyle="bold"
        android:layout_margin="7dip" android:text="Testing Customize Dialog"
        android:gravity="center"></TextView>
    <Button android:layout_width="60dip"
    android:layout_height="40dip" android:text="OK"
    android:id="@+id/OkButton"></Button>
</LinearLayout>






CustomizeDialog.java
package com.CustomDialog;
import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;

/** Class Must extends with Dialog */
/** Implement onClickListener to dismiss dialog when OK Button is pressed */
public class CustomizeDialog extends Dialog implements OnClickListener {
    Button okButton;

    public CustomizeDialog(Context context) {
        super(context);
        /** 'Window.FEATURE_NO_TITLE' - Used to hide the title */
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        /** Design the dialog in main.xml file */
        setContentView(R.layout.main);
        okButton = (Button) findViewById(R.id.OkButton);
        okButton.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        /** When OK Button is clicked, dismiss the dialog */
        if (v == okButton)
            dismiss();
    }

}


Activity:
CustomDialogExample.java
package com.CustomDialog;

import android.app.Activity;
import android.os.Bundle;

public class CustomDialogExample extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        /** Display Custom Dialog */
        CustomizeDialog customizeDialog = new CustomizeDialog(this);
        customizeDialog.show();
    }
}

1 comment:

  1. There is absolutely nothing inherently wrong with this particular so long since it's you're aware of it payday loans no fax payday loans -
    easier and swifter approach for funding.
    my web site :: payday loans

    ReplyDelete

Check out this may be help you

Related Posts Plugin for WordPress, Blogger...