12 Ocak 2018 Cuma

AlertDialog Sınıfı

constructor
Şöyle yaparız.
AlertDialog alertDialog = new AlertDialog.Builder(this).create();
constructor - protected
Protected olduğı için dışarıdan çağrılamaz. Metodun içi şöyle
protected AlertDialog(Context context) {
  this(context, 0);
}
constructor - protected
Protected olduğı için dışarıdan çağrılamaz. Metodun içi şöyle
protected AlertDialog(Context context, @StyleRes int themeResId) {
  this(context, themeResId, true);
}
findViewById metodu
Düğmelerin yerine değiştirmek için şöyle yaparız.
Button posBtn = (Button) alertDialog.findViewById(android.R.id.button1);
Button negBtn = (Button) alertDialog.findViewById(android.R.id.button2);
Button neuBtn = (Button) alertDialog.findViewById(android.R.id.button3);

//get parent ViewGroup
 ViewGroup parentLayout = (ViewGroup) posBtn.getParent();

//get child indexes
int posIndex = parentLayout.indexOfChild(posBtn);
int negindex = parentLayout.indexOfChild(negBtn);
int neuIndex = parentLayout.indexOfChild(neuBtn);

 parentLayout.removeAllViews();
 parentLayout.addView(neuIndex,posBtn); //< --- swapping neutral and positive
 parentLayout.addView(posIndex,neuBtn);
 parentLayout.addView(negIndex,negBtn); 
setButton metodu
Şöyle yaparız.
// Setting OK Button
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
  public void onClick(DialogInterface dialog, int which) {

  }
});
setMessage metodu
Şöyle yaparız.
// Setting Dialog Message
alertDialog.setMessage(msg);
setTitle metodu
Şöyle yaparız.
// Setting Dialog Title
alertDialog.setTitle("ERROR");
show metodu
Şöyle yaparız.
// Showing Alert Message
alertDialog.show();


Hiç yorum yok:

Yorum Gönder