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


Java Builder.setSingleChoiceItems方法代码示例

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


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

示例1: onPrepareDialogBuilder

import android.app.AlertDialog.Builder; //导入方法依赖的package包/类
@Override
protected void onPrepareDialogBuilder(Builder builder) {

    // do again, maybe an app has now been installed
    populateAppList();

    // Init ArrayAdapter with OpenPGP Providers
    ListAdapter adapter = new ArrayAdapter<OpenPgpProviderEntry>(getContext(),
            android.R.layout.select_dialog_singlechoice, android.R.id.text1, mList) {
        public View getView(int position, View convertView, ViewGroup parent) {
            // User super class to create the View
            View v = super.getView(position, convertView, parent);
            TextView tv = (TextView) v.findViewById(android.R.id.text1);

            // Put the image on the TextView
            tv.setCompoundDrawablesWithIntrinsicBounds(mList.get(position).icon, null,
                    null, null);

            // Add margin between image and text (support various screen densities)
            int dp10 = (int) (10 * getContext().getResources().getDisplayMetrics().density + 0.5f);
            tv.setCompoundDrawablePadding(dp10);

            return v;
        }
    };

    builder.setSingleChoiceItems(adapter, getIndexOfProviderList(mSelectedPackage),
            new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    OpenPgpProviderEntry entry = mList.get(which);

                    if (entry.intent != null) {
                        /*
                         * Intents are called as activity
                         *
                         * Current approach is to assume the user installed the app.
                         * If he does not, the selected package is not valid.
                         *
                         * However  applications should always consider this could happen,
                         * as the user might remove the currently used OpenPGP app.
                         */
                        getContext().startActivity(entry.intent);
                        return;
                    }

                    mSelectedPackage = entry.packageName;

                    /*
                     * Clicking on an item simulates the positive button click, and dismisses
                     * the dialog.
                     */
                    OpenPgpAppPreference.this.onClick(dialog, DialogInterface.BUTTON_POSITIVE);
                    dialog.dismiss();
                }
            });

    /*
     * The typical interaction for list-based dialogs is to have click-on-an-item dismiss the
     * dialog instead of the user having to press 'Ok'.
     */
    builder.setPositiveButton(null, null);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:65,代码来源:OpenPgpAppPreference.java

示例2: showFilterDialog

import android.app.AlertDialog.Builder; //导入方法依赖的package包/类
protected void showFilterDialog() {
    int i = 0;
    Builder builder = new Builder(getParentActivity());
    builder.setTitle(R.string.filter_title);
    CharSequence[] charSequenceArr = new CharSequence[]{getParentActivity().getString(R.string.AllChanges), getParentActivity().getString(R.string.change_name), getParentActivity().getString(R.string.change_photo), getParentActivity().getString(R.string.change_phone)};
    if (this.currentFilterType != 0) {
        i = this.currentFilterType - 1;
    }
    builder.setSingleChoiceItems(charSequenceArr, i, new C20985());
    showDialog(builder.create());
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:12,代码来源:UpdateActivity.java

示例3: onPrepareDialogBuilder

import android.app.AlertDialog.Builder; //导入方法依赖的package包/类
@Override
protected void onPrepareDialogBuilder(Builder builder) {

    // do again, maybe an app has now been installed
    populateAppList();

    // Init ArrayAdapter with OpenPGP Providers
    ListAdapter adapter = new ArrayAdapter<OpenPgpProviderEntry>(getContext(),
            android.R.layout.select_dialog_singlechoice, android.R.id.text1, mList) {
        public View getView(int position, View convertView, ViewGroup parent) {
            // User super class to create the View
            View v = super.getView(position, convertView, parent);
            TextView tv = (TextView) v.findViewById(android.R.id.text1);

            // Put the image on the TextView
            tv.setCompoundDrawablesWithIntrinsicBounds(mList.get(position).icon, null,
                    null, null);

            // Add margin between image and text (support various screen densities)
            int dp10 = (int) (10 * getContext().getResources().getDisplayMetrics().density + 0.5f);
            tv.setCompoundDrawablePadding(dp10);

            return v;
        }
    };

    builder.setSingleChoiceItems(adapter, getIndexOfProviderList(mSelectedPackage),
            new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    OpenPgpProviderEntry entry = mList.get(which);

                    if (entry.intent != null) {
                        /*
                         * Intents are called as activity
                         *
                         * Current approach is to assume the user installed the app.
                         * If he does not, the selected package is not valid.
                         *
                         * However  applications should always consider this could happen,
                         * as the user might remove the currently used OpenPGP app.
                         */
                        getContext().startActivity(entry.intent);
                        return;
                    }

                    mSelectedPackage = entry.packageName;

                    /*
                     * Clicking on an item simulates the positive button click, and dismisses
                     * the dialog.
                     */
                    SMimeAppPreference.this.onClick(dialog, DialogInterface.BUTTON_POSITIVE);
                    dialog.dismiss();
                }
            });

    /*
     * The typical interaction for list-based dialogs is to have click-on-an-item dismiss the
     * dialog instead of the user having to press 'Ok'.
     */
    builder.setPositiveButton(null, null);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:65,代码来源:SMimeAppPreference.java


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