Home » » Android Simple AlertDialog Example

Android Simple AlertDialog Example

Written By MR HARI on Senin, 11 April 2011 | 22.34


SIMPLE ALERTDIALOG

SOURCE CODE is

package com.AlertDialogExample;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;

public class AlertDialogExample extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
                super.onCreate(savedInstanceState);
                setContentView(R.layout.main);
               
                AlertDialog.Builder adb = new AlertDialog.Builder(this);
                adb.setTitle("Set Title here");
                adb.setMessage("Set the Text Message here");
                adb.setPositiveButton("Ok", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int id)
{
// Action for 'Ok' Button
                                }
                });
                adb.setNegativeButton("Cancel", new DialogInterface.OnClickListener()
{
                                public void onClick(DialogInterface dialog, int id)
                                                {
                                                // Action for 'Cancel' Button
                                                dialog.cancel();
                                }
                });
                adb.setIcon(R.drawable.icon);
adb.show();
}
}

The OUTPUT will be


https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikkaBN3Jgi5Hrj5EzN43KA0EFkCBm0dY4Gka5dEEfd7-c3qOGu6wqnD8FybF7E1XwbvFDeDFv5gfkhuu14i4zQtvnfv3HoRQgSfNU0Rcz6Y4kgUIOD2X-SLZ-ojkHy-l3w-ovokaXyySQ/
Share this article :

0 komentar:

Posting Komentar

 
Support : Your Link | Your Link | Your Link
Copyright © 2013. Android Center - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger