12 Ocak 2018 Cuma

AlertDialog.Builder Sınıfı

constructor
Activity nesnesinin context alanını alır. Bir düğmenin click olayı içinde kodlamak istersek şöyle yaparız.
AlertDialog.Builder builder = new AlertDialog.Builder (MyActivity.this);
Şöyle yaparız.
builder = AlertDialog.Builder(context, R.style.MyAlertDialogTheme);
create metodu
Şöyle yaparız.
AlertDialog alert = builder.create();
setCancellable metodu
Şöyle yaparız.
builder.setCancelable(false)
setItems metodu
Şöyle yaparız
builder.setItems(R.array.preference_grid_entries, gridDialogListener);
setMessage metodu
Şöyle yaparız.
builder.setMessage("GPS is not active. Do you want to open?");
setNegativeButton metodu
Şöyle yaparız.
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
  public void onClick(DialogInterface dialog, int which) {
    dialog.cancel();
  }
});
setOnDismissListener metodu
Şöyle yaparız.
builder.setOnDismissListener(new DialogInterface.OnDismissListener() {

  public void onDismiss(DialogInterface dialog) {
  ...
   }
});
setPositiveButton metodu
Şöyle yaparız.
builder.setPositiveButton(android.R.string.ok, null);
Şöyle yaparız.
builder.setPositiveButton("Settings", new DialogInterface.OnClickListener() {
  public void onClick(DialogInterface dialog,int which) {
    ...
  }
});
setTitle metodu
Şöyle yaparız.
builder.setTitle("GPS Settings");
setView metodu
Şöyle yaparız.
View promptView = ...;
builder.setView(promptView);
show metodu
Şöyle yaparız.
// Showing Alert Message
builder.show();

Hiç yorum yok:

Yorum Gönder