Learn Android for Free,issues for developers, mobengineers website provide complete solutions for developers issues posts.It also provides online training for android development

Wednesday, June 5, 2013

Custom Dialog Android

package com.mobengineers;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

public class DashboardActivity extends Activity {
    private static final int DIALOG_CUSTOM_ANIMATION = 1;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }

    public void onButtonDownUpActivityClick(View view) {
        startActivity(new Intent(this, DownUpActivity.class));
    }

    public void onButtonDialogClick(View view) {
        showDialog(DIALOG_CUSTOM_ANIMATION);
    }

    @Override
    protected Dialog onCreateDialog(int id) {
        switch (id) {
        case DIALOG_CUSTOM_ANIMATION:
            CustomAlertDialog dialog = new CustomAlertDialog(this);
            dialog.setTitle("Swich on Location providers for better !");
            dialog.setCancelable(true);
            dialog.setMessage("How this dialog....  just for fun)");
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setButton("Settings", new DialogInterface.OnClickListener() {
               
                @Override
                public void onClick(DialogInterface dialog, int which) {
                
                    dialog.dismiss();// TODO Auto-generated method stub
                   
                }
            });

            WindowManager.LayoutParams wmlp = dialog.getWindow()
                    .getAttributes();

            wmlp.gravity = Gravity.TOP;

            dialog.show();
            return dialog;
        }
        return super.onCreateDialog(id);
    }
}

0 coment�rios:

Post a Comment

20% off

Online Training

Your Name :
Your Email: (required)
Your Message: (required)

NDTV Gadgets360

Powered by Blogger.

Recent Posts

Find Us On Facebook

Popular Posts