Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void showDialog(final String title, final String message,
- final OnClickListener onClickPositive,
- final OnClickListener onCLickNegative, final String positiveButton,
- final String negativeButton, final boolean cancelable) {
- if (!isFinishing()) {
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- if (dialog != null && dialog.isShowing()) {
- dialog.cancel();
- }
- Builder builder;
- if (android.os.Build.VERSION.SDK_INT >= 14) {
- builder = new AlertDialog.Builder(new ContextThemeWrapper(
- MyActivity.this,
- android.R.style.Theme_DeviceDefault_Light_Dialog));
- } else {
- builder = new Builder(MyActivity.this);
- }
- if (title != null) {
- builder.setTitle(title);
- }
- if (message != null) {
- builder.setMessage(message);
- }
- if (positiveButton != null) {
- builder.setPositiveButton(positiveButton, onClickPositive);
- }
- if (negativeButton != null) {
- builder.setNegativeButton(negativeButton, onCLickNegative);
- }
- builder.setCancelable(cancelable);
- dialog = builder.show();
- colorizeDialog(dialog);
- }
- });
- }
- }
- //theme-xml
- <style name="Theme.DeviceDefault.Light.Dialog" parent="Theme.Holo.Light.Dialog" >
- <item name="android:windowTitleStyle">@android:style/DialogWindowTitle.DeviceDefault.Light</item>
- <item name="android:windowAnimationStyle">@android:style/Animation.DeviceDefault.Dialog</item>
- <item name="android:buttonBarStyle">@android:style/DeviceDefault.Light.ButtonBar.AlertDialog</item>
- <item name="borderlessButtonStyle">@android:style/Widget.DeviceDefault.Light.Button.Borderless.Small</item>
- <item name="textAppearance">@android:style/TextAppearance.DeviceDefault.Light</item>
- <item name="textAppearanceInverse">@android:style/TextAppearance.DeviceDefault.Light.Inverse</item>
- </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement