当前位置: 首页>>代码示例>>Java>>正文


Java AlertDialog.BUTTON_POSITIVE属性代码示例

本文整理汇总了Java中android.support.v7.app.AlertDialog.BUTTON_POSITIVE属性的典型用法代码示例。如果您正苦于以下问题:Java AlertDialog.BUTTON_POSITIVE属性的具体用法?Java AlertDialog.BUTTON_POSITIVE怎么用?Java AlertDialog.BUTTON_POSITIVE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.support.v7.app.AlertDialog的用法示例。


在下文中一共展示了AlertDialog.BUTTON_POSITIVE属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: showDownloadWarningDialog

/**
 * Shows a warning dialog indicating that download has failed. When user confirms
 * the warning, a message will be sent to the notification server to  inform about the
 * error.
 *
 * @param titleId The resource identifier for the title.
 * @param omaInfo Information about the OMA content.
 * @param downloadInfo Information about the download.
 * @param statusMessage Message to be sent to the notification server.
 */
private void showDownloadWarningDialog(
        int titleId, final OMAInfo omaInfo, final DownloadInfo downloadInfo,
        final String statusMessage) {
    DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (which == AlertDialog.BUTTON_POSITIVE) {
                sendInstallNotificationAndNextStep(omaInfo, downloadInfo,
                        DownloadItem.INVALID_DOWNLOAD_ID, statusMessage);
            }
        }
    };
    new AlertDialog.Builder(
            ApplicationStatus.getLastTrackedFocusedActivity(), R.style.AlertDialogTheme)
            .setTitle(titleId)
            .setPositiveButton(R.string.ok, clickListener)
            .setCancelable(false)
            .show();
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:29,代码来源:OMADownloadHandler.java

示例2: onClick

@Override
public void onClick(DialogInterface dialogInterface, int which) {
    switch (which)
    {
        case AlertDialog.BUTTON_POSITIVE:
            break;

        case AlertDialog.BUTTON_NEGATIVE:
            // se era gia presente una key, allora chiudo semplicmente il dialog,
            // altrimenti significa che non è mai stata inserita alcuna chiave, quindi chiudo l'app
            if(!SharedPrefsHelper.getInstance().isApiKeyRegistered(getActivity()))
                getActivity().finish();
            else
                dismiss();
            break;
    }
}
 
开发者ID:IelloDevTeam,项目名称:IelloAndroidAdminApp,代码行数:17,代码来源:DialogAPIKey.java

示例3: showNextUrlDialog

/**
 * Shows a dialog to ask whether user wants to open the nextURL.
 *
 * @param omaInfo Information about the OMA content.
 */
private void showNextUrlDialog(OMAInfo omaInfo) {
    if (omaInfo.isValueEmpty(OMA_NEXT_URL)) {
        return;
    }
    final String nextUrl = omaInfo.getValue(OMA_NEXT_URL);
    final Activity activity = ApplicationStatus.getLastTrackedFocusedActivity();
    DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (which == AlertDialog.BUTTON_POSITIVE) {
                Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(nextUrl));
                intent.putExtra(Browser.EXTRA_APPLICATION_ID, activity.getPackageName());
                intent.putExtra(Browser.EXTRA_CREATE_NEW_TAB, true);
                intent.setPackage(mContext.getPackageName());
                activity.startActivity(intent);
            }
        }
    };
    new AlertDialog.Builder(activity)
            .setTitle(R.string.open_url_post_oma_download)
            .setPositiveButton(R.string.ok, clickListener)
            .setNegativeButton(R.string.cancel, clickListener)
            .setMessage(nextUrl)
            .setCancelable(false)
            .show();
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:31,代码来源:OMADownloadHandler.java

示例4: onClick

@Override
public void onClick(DialogInterface dialog, int which) {
    if (which == AlertDialog.BUTTON_POSITIVE) {
        AccountManagementScreenHelper.logEvent(
                ProfileAccountManagementMetrics.SIGNOUT_SIGNOUT, mGaiaServiceType);

        mSignOutClicked = true;
        SignOutDialogListener targetFragment = (SignOutDialogListener) getTargetFragment();
        targetFragment.onSignOutClicked();
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:11,代码来源:SignOutDialogFragment.java

示例5: onOptionsItemSelected

@Override
public boolean onOptionsItemSelected(MenuItem _item) {
    if (_item.getItemId() == R.id.menu_folderAdd) {
        AlertDialog.Builder dialog = new AlertDialog.Builder(this);
        dialog.setTitle(R.string.folder_dialog_title_create);
        View layout = LayoutInflater.from(mContextThis).inflate(R.layout.dialog_folder_create, null);
        mEditText = (EditText) layout.findViewById(R.id.dialog_folder_input);
        dialog.setView(layout);
        DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface _dialog, int _which) {
                if (_which == AlertDialog.BUTTON_POSITIVE) {
                    mNewFolderName = mEditText.getText().toString();
                    if (!mNewFolderName.equals("")) {
                        File file = new File(Constant.APP_INTERNAL_URL + File.separator + mNewFolderName);
                        if (file.exists())
                            Snackbar.make(mContextView, R.string.folder_dialog_toast_exist, Snackbar.LENGTH_SHORT).show();
                        else {
                            file.mkdir();
                            runOnUiThread(mRefreshRunnable);
                        }
                    }
                }
                _dialog.dismiss();
            }
        };
        dialog.setNegativeButton(R.string.folder_dialog_button_cancel, clickListener);
        dialog.setPositiveButton(R.string.folder_dialog_button_create, clickListener);
        dialog.show();
    }
    return super.onOptionsItemSelected(_item);
}
 
开发者ID:Eskeptor,项目名称:OpenPad-for-Android,代码行数:32,代码来源:FolderActivity.java

示例6: deleteFolder

/**
 * 폴더를 삭제하는 메소드
 * @param _index 삭제할 폴더의 인덱스
 */
private void deleteFolder(final int _index) {
    AlertDialog.Builder dialog = new AlertDialog.Builder(this);
    dialog.setTitle(R.string.folder_dialog_title_delete);
    dialog.setMessage(R.string.folder_dialog_message_question_delete);
    DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface _dialog, int _which) {
            if (_which == AlertDialog.BUTTON_POSITIVE) {
                File file = new File(mFolders.get(_index).mFolderPath);
                if (file.exists()) {
                    if (!file.getName().equals(Constant.FOLDER_DEFAULT_NAME) && !file.getName().equals(Constant.FOLDER_WIDGET_NAME)
                            && file.delete()) {
                        Snackbar.make(mContextView, R.string.folder_dialog_toast_delete, Snackbar.LENGTH_LONG).show();
                        runOnUiThread(mRefreshRunnable);
                    } else {
                        Snackbar.make(mContextView, R.string.folder_toast_remove_defaultfolder, Snackbar.LENGTH_SHORT).show();
                    }
                } else {
                    Snackbar.make(mContextView, R.string.error_folder_not_exist, Snackbar.LENGTH_SHORT).show();
                }
            }
            _dialog.dismiss();
        }
    };
    dialog.setNegativeButton(R.string.folder_dialog_button_cancel, clickListener);
    dialog.setPositiveButton(R.string.folder_dialog_button_delete, clickListener);
    dialog.show();
}
 
开发者ID:Eskeptor,项目名称:OpenPad-for-Android,代码行数:32,代码来源:FolderActivity.java

示例7: deleteFile

/**
 * 메인 리스트에서 파일을 제거하는 메소드
 * @param _index 제거할 파일의 인덱스
 */
private void deleteFile(final int _index) {
    AlertDialog.Builder dialog = new AlertDialog.Builder(this);
    dialog.setTitle(R.string.file_dialog_title_delete);
    dialog.setMessage(R.string.file_dialog_message_question_delete);
    DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface _dialog, int _which) {
            if (_which == AlertDialog.BUTTON_POSITIVE) {
                File file = new File(mCurFolderFileList.get(_index).mFilePath);
                if (file.exists()) {
                    if (file.delete()) {
                        Snackbar.make(mContextView, R.string.file_dialog_toast_delete, Snackbar.LENGTH_SHORT).show();
                        mCurFolderFileList.remove(_index);
                        mCurFolderGridView.removeViewAt(_index);
                        mCurFileAdapter.notifyItemRemoved(_index);
                        mCurFileAdapter.notifyItemRangeChanged(_index, mCurFolderFileList.size());
                        mCurFileAdapter.notifyDataSetChanged();
                    } else {
                        Snackbar.make(mContextView, R.string.error_folder_not_exist, Snackbar.LENGTH_SHORT).show();
                    }
                }
            }
            _dialog.dismiss();
        }
    };
    dialog.setNegativeButton(R.string.folder_dialog_button_cancel, clickListener);
    dialog.setPositiveButton(R.string.folder_dialog_button_delete, clickListener);
    dialog.show();
}
 
开发者ID:Eskeptor,项目名称:OpenPad-for-Android,代码行数:33,代码来源:MainActivity.java

示例8: onCreateDialog

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // We check the domains and urls as well due to crbug.com/622879.
    if (savedInstanceState != null) {
        // The important domains and favicon URLs aren't currently saved, so if this dialog
        // is recreated from a saved instance they will be null. This method must return a
        // valid dialog, so these two array's are initialized, then the dialog is dismissed.
        // TODO(dmurph): save mImportantDomains and mFaviconURLs so that they can be restored
        // from a savedInstanceState and the dialog can be properly recreated rather than
        // dismissed.
        mImportantDomains = new String[0];
        mFaviconURLs = new String[0];
        dismiss();
    }
    mProfile = Profile.getLastUsedProfile().getOriginalProfile();
    mLargeIconBridge = new LargeIconBridge(mProfile);
    ActivityManager activityManager =
            ((ActivityManager) ContextUtils.getApplicationContext().getSystemService(
                    Context.ACTIVITY_SERVICE));
    int maxSize = Math.min(
            activityManager.getMemoryClass() / 16 * 25 * 1024, FAVICON_MAX_CACHE_SIZE_BYTES);
    mLargeIconBridge.createCache(maxSize);

    mAdapter = new ClearBrowsingDataAdapter(mImportantDomains, mFaviconURLs, getResources());
    DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (which == AlertDialog.BUTTON_POSITIVE) {
                Intent data = new Intent();
                List<String> deselectedDomains = new ArrayList<>();
                List<Integer> deselectedDomainReasons = new ArrayList<>();
                List<String> ignoredDomains = new ArrayList<>();
                List<Integer> ignoredDomainReasons = new ArrayList<>();
                for (Entry<String, Boolean> entry : mCheckedState.entrySet()) {
                    Integer reason = mImportantDomainsReasons.get(entry.getKey());
                    if (entry.getValue()) {
                        ignoredDomains.add(entry.getKey());
                        ignoredDomainReasons.add(reason);
                    } else {
                        deselectedDomains.add(entry.getKey());
                        deselectedDomainReasons.add(reason);
                    }
                }
                data.putExtra(DESELECTED_DOMAINS_TAG, deselectedDomains.toArray(new String[0]));
                data.putExtra(
                        DESELECTED_DOMAIN_REASONS_TAG, toIntArray(deselectedDomainReasons));
                data.putExtra(IGNORED_DOMAINS_TAG, ignoredDomains.toArray(new String[0]));
                data.putExtra(IGNORED_DOMAIN_REASONS_TAG, toIntArray(ignoredDomainReasons));
                getTargetFragment().onActivityResult(
                        getTargetRequestCode(), Activity.RESULT_OK, data);
            } else {
                getTargetFragment().onActivityResult(getTargetRequestCode(),
                        Activity.RESULT_CANCELED, getActivity().getIntent());
            }
        }
    };
    // We create our own ListView, as AlertDialog doesn't let us set a message and a list
    // adapter at the same time.
    View messageAndListView = getActivity().getLayoutInflater().inflate(
            R.layout.clear_browsing_important_dialog_listview, null);
    mSitesListView = (ListView) messageAndListView.findViewById(R.id.select_dialog_listview);
    mSitesListView.setAdapter(mAdapter);
    mSitesListView.setOnItemClickListener(mAdapter);
    final AlertDialog.Builder builder =
            new AlertDialog.Builder(getActivity(), R.style.AlertDialogTheme)
                    .setTitle(R.string.storage_clear_site_storage_title)
                    .setPositiveButton(R.string.clear_browsing_data_important_dialog_button,
                            listener)
                    .setNegativeButton(R.string.cancel, listener)
                    .setView(messageAndListView);
    mDialog = builder.create();

    return mDialog;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:74,代码来源:ConfirmImportantSitesDialogFragment.java


注:本文中的android.support.v7.app.AlertDialog.BUTTON_POSITIVE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。