-> by passing DialogInterface.OnClickListener() object in parameters and implementing it in Activity class
AlertDialogs alertdialog;
alertdialog.SingleSelectDialog("title",otherParameters,new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
int x=alertdialog.getAmount();
}
});
-> in class AlertDialogs
public void SingleSelectWithImage(String head,otherParameters, DialogInterface.OnClickListener pressok) {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context, R.style.MyDialogTheme);
dialogBuilder.setTitle(head);
amount=bla_bla;
//do anything
dialogBuilder.setPositiveButton("ok", pressok);
dialogBuilder.setNegativeButton("Cancel", null);
dialogBuilder.show();
}
-> getter method
public int getAmount() {
return amount;
}