I have alert dialog and both PositiveButton and NegativeButton sited programmatically , i want to retrieve them from xml layout ,i try to do it but im new to android develop
XML Code:
Java Code:
// custom dialog
final Dialog dialog = new Dialog(context);
//name of xml - custom
dialog.setContentView(R.layout.custom);
// set the custom dialog components - text, image and button
Button dialogButtonOK = (Button) dialog.findViewById(R.id.dialogButtonOK);
Button dialogButtonCancell = (Button) dialog.findViewById(R.id.dialogButtonCancell);
dialog.setTitle("Warning!!!!!");
// if button is clicked, call some method..
dialogButtonOk.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
someMethod();
}
});
dialogButtonCancell.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();