Contain one class file like this AllMethod.javaand add this code to this class file.
public static void showAlert(Activity act, String msg, DialogInterface.OnClickListener listener) {
AlertDialog.Builder alert = new AlertDialog.Builder(act);
alert.setMessage(msg);
alert.setPositiveButton("OK", listener);
alert.show();
}
and you can use any class, for example, the code below.
AllMethod.showAlert(mActivity, "", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
source
share