Example usage for android.app Dialog requestWindowFeature

List of usage examples for android.app Dialog requestWindowFeature

Introduction

In this page you can find the example usage for android.app Dialog requestWindowFeature.

Prototype

public final boolean requestWindowFeature(int featureId) 

Source Link

Document

Enable extended window features.

Usage

From source file:com.cellobject.oikos.FormActivity.java

private void initializeSettingsAndInfoButtons() {
    preferencesBtn = (ImageButton) findViewById(R.id.preferences_btn);
    preferencesBtn.setOnClickListener(new View.OnClickListener() {
        public void onClick(final View view) {
            final Intent intent = new Intent(FormActivity.this, OikosPreferenceActivity.class);
            startActivity(intent);// ww w .  j a va 2s  .  co m
        }
    });
    infoBtn = (ImageButton) findViewById(R.id.info_btn);
    infoBtn.setOnClickListener(new View.OnClickListener() {
        public void onClick(final View view) {
            final Dialog dialog = new Dialog(FormActivity.this);
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setCancelable(true);
            dialog.setContentView(R.layout.info);
            final Button button = (Button) dialog.findViewById(R.id.aboutOk);
            button.setOnClickListener(new OnClickListener() {
                public void onClick(final View v) {
                    dialog.dismiss();
                }
            });
            dialog.show();
        }
    });
}

From source file:com.neighbor.ex.tong.ui.activity.MainActivity2Activity.java

private void showDialogAree() {
    final Dialog dialog = new Dialog(this);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

    dialog.setContentView(R.layout.dialog_agree); // custom_dialog.xml  ? layout  ?? view .
    WindowManager.LayoutParams params = dialog.getWindow().getAttributes();
    params.width = LinearLayout.LayoutParams.MATCH_PARENT;
    final CheckBox accountLicense = (CheckBox) dialog.findViewById(R.id.checkBoxAgree);
    final Button agreeBtn = (Button) dialog.findViewById(R.id.buttonAgree);
    final Button agreeCancelBtn = (Button) dialog.findViewById(R.id.buttonAgreeCancel);
    agreeBtn.setOnClickListener(new View.OnClickListener() {
        @Override//  w ww. j  a  v a2s .c  o m
        public void onClick(View view) {
            if (accountLicense.isChecked()) {
                SharedPreferenceManager.setValue(MainActivity2Activity.this,
                        SharedPreferenceManager.positionAgree, "true");
                dialog.dismiss();
            }
        }
    });
    agreeCancelBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            finish();
        }
    });
    dialog.setCancelable(false);
    dialog.setCanceledOnTouchOutside(false);
    dialog.show();
}

From source file:dev.datvt.cloudtracks.sound_cloud.LocalTracksFragment.java

public void showChangeLangDialog() {
    final Dialog dialog = new Dialog(ctx);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setCancelable(false);/*from   w ww .j a  v  a  2  s . c o  m*/
    dialog.setContentView(R.layout.dialog_create_playlist);

    final EditText edt = (EditText) dialog.findViewById(R.id.edtInput);
    final TextView btnCreate = (TextView) dialog.findViewById(R.id.btnCreate);
    final TextView btnCancel = (TextView) dialog.findViewById(R.id.btnCancel);
    final ImageView btnDel = (ImageView) dialog.findViewById(R.id.btnDel);

    btnCreate.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ret = edt.getText().toString();
            if (ret != null && !ret.isEmpty()) {
                try {
                    ToolsHelper.createPlaylist(ctx, ret);
                    setUpListPlaylist();
                    Log.d("CREATE_2", "COMPLETE");
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else {
                ToolsHelper.toast(ctx, getString(R.string.info_not_name_playlist));
                showChangeLangDialog();
            }
            dialog.dismiss();
        }
    });

    btnCancel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ret = null;
            dialog.cancel();
        }
    });

    btnDel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            edt.setText("");
        }
    });

    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    dialog.show();
}

From source file:org.rm3l.maoni.ui.MaoniActivity.java

private void initScreenCaptureView(@NonNull final Intent intent) {
    final ImageButton screenshotThumb = (ImageButton) findViewById(R.id.maoni_screenshot);

    final TextView touchToPreviewTextView = (TextView) findViewById(R.id.maoni_screenshot_touch_to_preview);
    if (touchToPreviewTextView != null && intent.hasExtra(SCREENSHOT_TOUCH_TO_PREVIEW_HINT)) {
        touchToPreviewTextView.setText(intent.getCharSequenceExtra(SCREENSHOT_TOUCH_TO_PREVIEW_HINT));
    }/*ww  w  .j a v  a2 s . c  om*/

    final View screenshotContentView = findViewById(R.id.maoni_include_screenshot_content);
    if (!TextUtils.isEmpty(mScreenshotFilePath)) {
        final File file = new File(mScreenshotFilePath.toString());
        if (file.exists()) {
            if (mIncludeScreenshot != null) {
                mIncludeScreenshot.setVisibility(View.VISIBLE);
            }
            if (screenshotContentView != null) {
                screenshotContentView.setVisibility(View.VISIBLE);
            }
            if (screenshotThumb != null) {
                //Thumbnail - load with smaller resolution so as to reduce memory footprint
                screenshotThumb.setImageBitmap(
                        ViewUtils.decodeSampledBitmapFromFilePath(file.getAbsolutePath(), 100, 100));
            }

            // Hook up clicks on the thumbnail views.
            if (screenshotThumb != null) {
                screenshotThumb.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {

                        final Dialog imagePreviewDialog = new Dialog(MaoniActivity.this);

                        imagePreviewDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                        imagePreviewDialog.getWindow()
                                .setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

                        imagePreviewDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
                            @Override
                            public void onDismiss(DialogInterface dialogInterface) {
                                //nothing;
                            }
                        });

                        imagePreviewDialog.setContentView(R.layout.maoni_screenshot_preview);

                        final View.OnClickListener clickListener = new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                imagePreviewDialog.dismiss();
                            }
                        };

                        final ImageView imageView = (ImageView) imagePreviewDialog
                                .findViewById(R.id.maoni_screenshot_preview_image);
                        imageView.setImageURI(Uri.fromFile(file));

                        final DrawableView drawableView = (DrawableView) imagePreviewDialog
                                .findViewById(R.id.maoni_screenshot_preview_image_drawable_view);
                        final DrawableViewConfig config = new DrawableViewConfig();
                        // If the view is bigger than canvas, with this the user will see the bounds
                        config.setShowCanvasBounds(true);
                        config.setStrokeWidth(57.0f);
                        config.setMinZoom(1.0f);
                        config.setMaxZoom(1.0f);
                        config.setStrokeColor(mHighlightColor);
                        final View decorView = getWindow().getDecorView();
                        config.setCanvasWidth(decorView.getWidth());
                        config.setCanvasHeight(decorView.getHeight());
                        drawableView.setConfig(config);
                        drawableView.bringToFront();

                        imagePreviewDialog.findViewById(R.id.maoni_screenshot_preview_pick_highlight_color)
                                .setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        config.setStrokeColor(mHighlightColor);
                                    }
                                });
                        imagePreviewDialog.findViewById(R.id.maoni_screenshot_preview_pick_blackout_color)
                                .setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        config.setStrokeColor(mBlackoutColor);
                                    }
                                });
                        imagePreviewDialog.findViewById(R.id.maoni_screenshot_preview_close)
                                .setOnClickListener(clickListener);

                        imagePreviewDialog.findViewById(R.id.maoni_screenshot_preview_undo)
                                .setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        drawableView.undo();
                                    }
                                });

                        imagePreviewDialog.findViewById(R.id.maoni_screenshot_preview_save)
                                .setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        ViewUtils.exportViewToFile(MaoniActivity.this,
                                                imagePreviewDialog.findViewById(
                                                        R.id.maoni_screenshot_preview_image_view_updated),
                                                new File(mScreenshotFilePath.toString()));
                                        initScreenCaptureView(intent);
                                        imagePreviewDialog.dismiss();
                                    }
                                });

                        imagePreviewDialog.setCancelable(true);
                        imagePreviewDialog.setCanceledOnTouchOutside(false);

                        imagePreviewDialog.show();
                    }
                });
            }
        } else {
            if (mIncludeScreenshot != null) {
                mIncludeScreenshot.setVisibility(View.GONE);
            }
            if (screenshotContentView != null) {
                screenshotContentView.setVisibility(View.GONE);
            }
        }
    } else {
        if (mIncludeScreenshot != null) {
            mIncludeScreenshot.setVisibility(View.GONE);
        }
        if (screenshotContentView != null) {
            screenshotContentView.setVisibility(View.GONE);
        }
    }
}

From source file:group.pals.android.lib.ui.filechooser.utils.ui.bookmark.BookmarkFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (BuildConfig.DEBUG)
        Log.d(_ClassName, "onCreateDialog()");

    Dialog dialog = new Dialog(getActivity(), R.style.Afc_Theme_Dialog_Dark);
    dialog.setCanceledOnTouchOutside(true);
    dialog.requestWindowFeature(Window.FEATURE_LEFT_ICON);
    dialog.setTitle(R.string.afc_title_bookmark_manager);
    dialog.setContentView(initContentView(dialog.getLayoutInflater(), null));
    dialog.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.afc_bookmarks_dark);

    return dialog;
}

From source file:org.mixare.MixListView.java

public void loadStopDetailsDialog(String title, StopMarker stop) {
    Dialog d = new Dialog(this) {
        public boolean onKeyDown(int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_BACK)
                this.dismiss();
            return true;
        }/* w  ww.java2  s.  c  o m*/
    };

    d.requestWindowFeature(Window.FEATURE_NO_TITLE);
    d.getWindow().setGravity(Gravity.CENTER);
    d.setContentView(R.layout.stopdetailsdialog);

    TextView titleView = (TextView) d.findViewById(R.id.stopDetailDialogTitle);
    titleView.setText(title);

    ExpandableListView list = (ExpandableListView) d.findViewById(R.id.stopDetailDialogRouteList);

    final Button button = (Button) d.findViewById(R.id.stopWalkRouteButton);
    final double longitude = stop.getLongitude();
    final double latitude = stop.getLatitude();

    final Location start = mixContext.getCurrentLocation();

    button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Intent mapIntent = new Intent(org.mixare.maps.HelloGoogleMapsActivity.class.getName());
            mapIntent.putExtra("startLocation", start);
            mapIntent.putExtra("destLat", latitude);
            mapIntent.putExtra("destLong", longitude);

            startActivity(mapIntent);
        }
    });

    List<Map<String, ?>> groupMaps = stop.getRouteList();
    List<List<Map<String, ?>>> childMaps = stop.getRouteSubdataList();

    SimpleExpandableListAdapter adapter = new SimpleExpandableListAdapter(this, groupMaps,
            R.layout.stopdetailsdialogitemroute, new String[] { "id", "name" },
            new int[] { R.id.routeNumber, R.id.routeName }, childMaps, R.layout.stopdetailsdialogroutevariation,
            new String[] { "direction", "name", "times" },
            new int[] { R.id.routeVariationDirection, R.id.routeVariationName, R.id.routeVariationTimes });

    list.setAdapter(adapter);

    d.show();

    new StopTimesTask(adapter, stop).execute(groupMaps, childMaps);
}

From source file:edu.berkeley.boinc.PrefsActivity.java

public void onItemClick(View view) {
    final Dialog dialog = new Dialog(this);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    Object item = view.getTag();/*from   ww  w .j  a  va2 s .  c o m*/

    if (item instanceof PrefsListItemWrapperValue) {
        final PrefsListItemWrapperValue valueWrapper = (PrefsListItemWrapperValue) item;
        if (Logging.DEBUG)
            Log.d(Logging.TAG, "PrefsActivity onItemClick Value " + valueWrapper.ID);

        if (valueWrapper.isPct) {
            // show dialog with slider
            dialog.setContentView(R.layout.prefs_layout_dialog_pct);
            // setup slider
            TextView sliderProgress = (TextView) dialog.findViewById(R.id.seekbar_status);
            sliderProgress.setText(valueWrapper.status.intValue() + " " + getString(R.string.prefs_unit_pct));
            Double seekBarDefault = valueWrapper.status / 10;
            SeekBar slider = (SeekBar) dialog.findViewById(R.id.seekbar);
            slider.setProgress(seekBarDefault.intValue());
            slider.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                    String progressString = (progress * 10) + " " + getString(R.string.prefs_unit_pct);
                    TextView sliderProgress = (TextView) dialog.findViewById(R.id.seekbar_status);
                    sliderProgress.setText(progressString);
                }

                @Override
                public void onStartTrackingTouch(SeekBar seekBar) {
                }

                @Override
                public void onStopTrackingTouch(SeekBar seekBar) {
                }
            });
        } else if (valueWrapper.isNumber) {
            if (!getHostInfo()) {
                if (Logging.WARNING)
                    Log.w(Logging.TAG, "onItemClick missing hostInfo");
                return;
            }

            // show dialog with slider
            dialog.setContentView(R.layout.prefs_layout_dialog_pct);
            TextView sliderProgress = (TextView) dialog.findViewById(R.id.seekbar_status);
            sliderProgress.setText("" + valueWrapper.status.intValue());
            SeekBar slider = (SeekBar) dialog.findViewById(R.id.seekbar);

            // slider setup depending on actual preference
            if (valueWrapper.ID == R.string.prefs_cpu_number_cpus_header) {
                slider.setMax(hostinfo.p_ncpus);
                slider.setProgress(valueWrapper.status.intValue());
                slider.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                    public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                        if (progress == 0)
                            progress = 1; // do not allow 0 cpus
                        String progressString = String.valueOf(progress);
                        TextView sliderProgress = (TextView) dialog.findViewById(R.id.seekbar_status);
                        sliderProgress.setText(progressString);
                    }

                    @Override
                    public void onStartTrackingTouch(SeekBar seekBar) {
                    }

                    @Override
                    public void onStopTrackingTouch(SeekBar seekBar) {
                    }
                });
            } else if (valueWrapper.ID == R.string.prefs_gui_log_level_header) {
                slider.setMax(5);
                slider.setProgress(valueWrapper.status.intValue());
                slider.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                    public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                        String progressString = String.valueOf(progress);
                        TextView sliderProgress = (TextView) dialog.findViewById(R.id.seekbar_status);
                        sliderProgress.setText(progressString);
                    }

                    @Override
                    public void onStartTrackingTouch(SeekBar seekBar) {
                    }

                    @Override
                    public void onStopTrackingTouch(SeekBar seekBar) {
                    }
                });
            }
        } else {
            // show dialog with edit text
            dialog.setContentView(R.layout.prefs_layout_dialog);
        }
        // show preference name
        ((TextView) dialog.findViewById(R.id.pref)).setText(valueWrapper.ID);

        // setup buttons
        Button confirm = (Button) dialog.findViewById(R.id.confirm);
        confirm.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                double value = 0.0;
                Boolean clientPref = true;
                if (valueWrapper.isPct) {
                    SeekBar slider = (SeekBar) dialog.findViewById(R.id.seekbar);
                    value = slider.getProgress() * 10;
                } else if (valueWrapper.isNumber) {
                    SeekBar slider = (SeekBar) dialog.findViewById(R.id.seekbar);
                    int sbProgress = slider.getProgress();
                    if (valueWrapper.ID == R.string.prefs_cpu_number_cpus_header) {
                        if (sbProgress == 0)
                            sbProgress = 1;
                        value = numberCpuCoresToPct(sbProgress);
                    } else if (valueWrapper.ID == R.string.prefs_gui_log_level_header) {
                        appPrefs.setLogLevel(sbProgress);
                        updateValuePref(valueWrapper.ID, (double) sbProgress);
                        clientPref = false; // avoid writing client prefs via rpc
                        updateLayout();
                    }
                } else {
                    EditText edit = (EditText) dialog.findViewById(R.id.Input);
                    String input = edit.getText().toString();
                    Double valueTmp = parseInputValueToDouble(input);
                    if (valueTmp == null)
                        return;
                    value = valueTmp;
                }
                if (clientPref)
                    writeClientValuePreference(valueWrapper.ID, value);
                dialog.dismiss();
            }
        });
        Button cancel = (Button) dialog.findViewById(R.id.cancel);
        cancel.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });

        dialog.show();

    } else {
        // instance of PrefsListItemWrapper, i.e. client log flags
        PrefsListItemWrapper wrapper = (PrefsListItemWrapper) item;
        if (Logging.DEBUG)
            Log.d(Logging.TAG, "PrefsActivity onItemClick super " + wrapper.ID);

        dialog.setContentView(R.layout.prefs_layout_dialog_selection);
        final ArrayList<ClientLogOption> options = new ArrayList<ClientLogOption>();
        String[] array = getResources().getStringArray(R.array.prefs_client_log_flags);
        for (String option : array)
            options.add(new ClientLogOption(option));
        ListView lv = (ListView) dialog.findViewById(R.id.selection);
        new PrefsLogOptionsListAdapter(this, lv, R.id.selection, options);

        // setup buttons
        Button confirm = (Button) dialog.findViewById(R.id.confirm);
        confirm.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                ArrayList<String> selectedOptions = new ArrayList<String>();
                for (ClientLogOption option : options)
                    if (option.selected)
                        selectedOptions.add(option.name);
                if (Logging.DEBUG)
                    Log.d(Logging.TAG, selectedOptions.size() + " log flags selected");
                new SetCcConfigAsync().execute(formatOptionsToCcConfig(selectedOptions));
                dialog.dismiss();
            }
        });
        Button cancel = (Button) dialog.findViewById(R.id.cancel);
        cancel.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });

        dialog.show();
    }
}

From source file:com.near.chimerarevo.fragments.CommentsFragment.java

@SuppressLint("SetJavaScriptEnabled")
private void loadDisqusOAuth() {
    if (getActivity().getSharedPreferences(Constants.PREFS_TAG, Context.MODE_PRIVATE)
            .getString(Constants.KEY_REFRESH_TOKEN, "").length() > 1) {

        RequestBody formBody = new FormEncodingBuilder().add("grant_type", "refresh_token")
                .add("client_id", Constants.DISQUS_API_KEY).add("client_secret", Constants.DISQUS_API_SECRET)
                .add("refresh_token",
                        getActivity().getSharedPreferences(Constants.PREFS_TAG, Context.MODE_PRIVATE)
                                .getString(Constants.KEY_REFRESH_TOKEN, ""))
                .build();/*from w  ww . j a  v  a  2  s.  c  o  m*/

        Request request = new Request.Builder().url(Constants.DISQUS_TOKEN_URL).post(formBody).tag(FRAGMENT_TAG)
                .build();

        if (mDialog == null)
            mDialog = ProgressDialogUtils.getInstance(getActivity(), R.string.text_login);
        else
            mDialog = ProgressDialogUtils.modifyInstance(mDialog, R.string.text_login);

        mDialog.show();
        OkHttpUtils.getInstance().newCall(request).enqueue(new PostAccessTokenCallback());

        return;
    }

    final Dialog dialog = new Dialog(getActivity());

    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.webview_layout);
    dialog.setCancelable(true);

    dialog.setOnCancelListener(new OnCancelListener() {
        @Override
        public void onCancel(DialogInterface arg0) {
            isDialogOpen = false;
            mFab.show();
        }
    });
    dialog.setOnDismissListener(new OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface arg0) {
            isDialogOpen = false;
            mFab.show();
        }
    });

    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT)
        CookieManager.getInstance().removeAllCookies(null);
    else {
        CookieSyncManager.createInstance(getActivity());
        CookieManager.getInstance().removeAllCookie();
    }

    WebView wv = (WebView) dialog.findViewById(R.id.webview);
    wv.getSettings().setJavaScriptEnabled(true);
    wv.getSettings().setSaveFormData(false);
    wv.setWebViewClient(new WebViewClient() {

        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            dialog.findViewById(R.id.progressContainer).setVisibility(View.GONE);
            dialog.findViewById(R.id.webViewContainer).setVisibility(View.VISIBLE);
        }

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            super.onPageStarted(view, url, favicon);
            dialog.findViewById(R.id.progressContainer).setVisibility(View.VISIBLE);
            dialog.findViewById(R.id.webViewContainer).setVisibility(View.GONE);
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            boolean state = super.shouldOverrideUrlLoading(view, url);
            if (url.contains(Constants.SITE_URL)) {
                String code = url.split("code=")[1];

                RequestBody formBody = new FormEncodingBuilder().add("grant_type", "authorization_code")
                        .add("client_id", Constants.DISQUS_API_KEY)
                        .add("client_secret", Constants.DISQUS_API_SECRET)
                        .add("redirect_uri", Constants.SITE_URL).add("code", code).build();

                Request request = new Request.Builder().url(Constants.DISQUS_TOKEN_URL).post(formBody)
                        .tag(FRAGMENT_TAG).build();

                if (mDialog == null)
                    mDialog = ProgressDialogUtils.getInstance(getActivity(), R.string.text_login);
                else
                    mDialog = ProgressDialogUtils.modifyInstance(mDialog, R.string.text_login);

                dialog.dismiss();
                mDialog.show();

                OkHttpUtils.getInstance().newCall(request).enqueue(new PostAccessTokenCallback());
            }
            return state;
        }

        @Override
        public void onReceivedSslError(WebView view, @NonNull SslErrorHandler handler, SslError error) {
            handler.proceed();
        }

    });
    wv.loadUrl(URLUtils.getDisqusAuthUrl());

    isDialogOpen = true;
    mFab.hide();
    dialog.show();
}

From source file:com.emergencyskills.doe.aed.UI.activity.TabsActivity.java

@Override
public void onBackPressed() {

    if (checkcurrentfragment())

    {//  ww w .  j  av  a  2s . c  o m
        final Dialog dialog = new Dialog(TabsActivity.this);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.setContentView(R.layout.dialog_leaving_confirmation);
        dialog.getWindow()
                .setBackgroundDrawable(new ColorDrawable(getResources().getColor(android.R.color.transparent)));

        Button yes = (Button) dialog.findViewById(R.id.yesbtn);
        yes.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
                showpickupschool();

            }
        });
        Button no = (Button) dialog.findViewById(R.id.nobtn);
        no.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
        ImageView close = (ImageView) dialog.findViewById(R.id.ivClose);
        close.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });

        dialog.show();
    } else {
        super.onBackPressed();
    }
}

From source file:com.haibison.android.anhuu.utils.ui.bookmark.BookmarkFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (BuildConfig.DEBUG)
        Log.d(CLASSNAME, "onCreateDialog()");

    Dialog dialog = new Dialog(getActivity(),
            UI.resolveAttribute(getActivity(), R.attr.anhuu_f5be488d_theme_dialog));
    dialog.setCanceledOnTouchOutside(true);
    dialog.requestWindowFeature(Window.FEATURE_LEFT_ICON);
    dialog.setTitle(R.string.anhuu_f5be488d_title_bookmark_manager);
    dialog.setContentView(initContentView(dialog.getLayoutInflater(), null));
    dialog.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.anhuu_f5be488d_bookmarks_dark);

    return dialog;
}