OK ¸Þ¼¼Áö ¹Ú½º
OK ¹öÆ°ÀÌ ÀÖ´Â ¸Þ¼¼Áö ¹Ú½º¸¦ ¸¸µé·Á¸é ´ÙÀ½°ú °°ÀÌ ÇÑ´Ù.
OK ¹öÆ°À» Ŭ¸¯ÇßÀ»¶§, ¸®½º³Ê °ªÀº null·Î ÇÏ¿© ¾Æ¹« 󸮵µ ÇÏÁö ¾Ê´Â´Ù.
AlertDialog.Builder msg = new AlertDialog.Builder(getContext());
msg.setTitle( "Notice");
msg.setMessage("Go!");
msg.setPositiveButton("OK", null);
msg.show();
|
Yes, No ¸Þ¼¼Áö ¹Ú½º
Yes, No ¹öÆ°ÀÇ ¼±Åÿ¡ µû¶ó 󸮸¦ ´Þ¸® ÇÒ¼ö ÀÖµµ·Ï ¸®½º³Ê¸¦ ¼³Á¤ÇÑ´Ù.
AlertDialog.Builder alertdlg = new AlertDialog.Builder(getContext());
alertdlg.setTitle( "Notice");
alertdlg.setMessage("Are you ready?");
alertdlg.setPositiveButton("Yes", listener);
alertdlg.setNegativeButton("No", listener);
alertdlg.show();
|
¸®½º³Ê´Â À̸§ ¾ø´Â Ŭ·¡½º¸¦ »ç¿ëÇÏ¿© ±¸ÇöÇÑ´Ù.
DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener()
{
@Override
public void onClick( DialogInterface dlg, int which)
{
...........
}
};
|
À̸§ ¾ø´Â Ŭ·¡½º :
Ŭ·¡½º À̸§ÀÌ ÇÊ¿ä ¾ø´Â Áö¿ª Ŭ·¡½ºÀÌ´Ù.
°£´ÜÇÏ°Ô »ç¿ë ÇÒ¼ö Àִ Ŭ·¡½ºÀÌ´Ù.
»ý¼ºÀÚ¸¦ °¡Áú¼ö ¾ø´Ù.
interface Inter
{
public void hi();
}
Inter obj1 = new Inter()
{
public void hi()
{
System.out.println("¾È³çÇϽʴϱî?");
}
};
obj1.hi(); |
Àüü ÄÚµå´Â ´ÙÀ½°ú °°´Ù.
package com.example.helloworld;
import android.view.MotionEvent;
import android.view.View;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Color;
public class HelloView extends View
{
public HelloView( Context context)
{
super( context);
setBackgroundColor( Color.WHITE);
setFocusable(true);
}
@Override
public boolean onTouchEvent( MotionEvent event)
{
int action = event.getAction();
if((action & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP)
{
DialogInterface.OnClickListener listener = new
DialogInterface.OnClickListener()
{
@Override
public void onClick( DialogInterface dlg, int which)
{
if(which ==
DialogInterface.BUTTON_POSITIVE)
{
AlertDialog.Builder msg = new AlertDialog.Builder(getContext());
msg.setTitle(
"Notice");
msg.setMessage("Go!");
msg.setPositiveButton("OK", null);
msg.show();
}
else if(which ==
DialogInterface.BUTTON_NEGATIVE)
{
}
}
};
AlertDialog.Builder alertdlg = new AlertDialog.Builder(getContext());
alertdlg.setTitle( "Notice");
alertdlg.setMessage("Are you ready?");
alertdlg.setPositiveButton("Yes", listener);
alertdlg.setNegativeButton("No", listener);
alertdlg.show();
}
return true;
}
}
|
|