Java Code Examples for android.content.DialogInterface.OnMultiChoiceClickListener

The following are top voted examples for showing how to use android.content.DialogInterface.OnMultiChoiceClickListener. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: FlyWoo   File: AlertDialogUtils.java   View source code 6 votes vote down vote up
/**
 * @param context
 * @param s
 * @param okcallback
 */
public static void showSelectFriends(Context context, final String[] s, final MultCallBack okcallback) {
    new Builder(context).setMultiChoiceItems(s, new boolean[]{},
            new OnMultiChoiceClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which, boolean isChecked) {
                    List<Integer> checked = new ArrayList<Integer>();
                    for (int i = 0; i < s.length; i++) {
                        if (i == which && isChecked) {
                            // ��ʾѡ����
                            checked.add(i);
                        }
                    }
                    okcallback.onOkClick(checked);
                    dialog.dismiss();
                }
            }).show();
}
 
Example 2
Project: AndroidMaterialDialog   File: PreferenceFragment.java   View source code 6 votes vote down vote up
/**
 * Creates and returns a listener, which allows to show a toast, which indicates when a multi
 * choice list item of a dialog has been selected or unselected.
 *
 * @return The listener, which has been created, as an instance of the type {@link
 * OnClickListener}
 */
private OnMultiChoiceClickListener createMultiChoiceListener() {
    return new OnMultiChoiceClickListener() {

        @Override
        public void onClick(final DialogInterface dialog, final int position,
                            final boolean isChecked) {
            String text = getString(R.string.multi_choice_listener_selected_text);

            if (!isChecked) {
                text = getString(R.string.multi_choice_listener_unselected_text);
            }

            if (toast != null) {
                toast.cancel();
            }

            showToast(String.format(text, position));
        }

    };
}
 
Example 3
Project: AndroidMaterialPreferences   File: MultiChoiceListPreference.java   View source code 6 votes vote down vote up
/**
 * Creates and returns a listener, which allows to observe when list items are selected or
 * unselected by the user.
 *
 * @return The listener, which has been created, as an instance of the type {@link
 * OnMultiChoiceClickListener}
 */
private OnMultiChoiceClickListener createListItemListener() {
    return new OnMultiChoiceClickListener() {

        @Override
        public void onClick(final DialogInterface dialog, final int which,
                            final boolean isChecked) {
            if (isChecked) {
                selectedIndices.add(which);
            } else {
                selectedIndices.remove(which);
            }
        }

    };
}
 
Example 4
Project: Conquer   File: AlertDialogUtils.java   View source code 6 votes vote down vote up
/**
 * 多选对话框
 * 
 * @param context
 * @param s
 * @param okcallback
 */
public static void showSelectFriends(Context context, final String[] s, final MultCallBack okcallback) {
    new Builder(context).setMultiChoiceItems(s, new boolean[] {},
            new OnMultiChoiceClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which, boolean isChecked) {
                    List<Integer> checked = new ArrayList<Integer>();
                    for (int i = 0; i < s.length; i++) {
                        if (i == which && isChecked) {
                            // 表示选中了
                            checked.add(i);
                        }
                    }
                    okcallback.onOkClick(checked);
                    dialog.dismiss();
                }
            }).show();
}
 
Example 5
Project: WarDroid   File: MultiSelectListPreference.java   View source code 6 votes vote down vote up
@Override
protected void onPrepareDialogBuilder(Builder builder) {
    updateCheckedEntryIndexes();
    List<CharSequence> entriesList = new ArrayList<CharSequence>();
    entriesList.addAll(Arrays.asList(getEntries()));
    CharSequence[] entries = entriesList.toArray(new CharSequence[entriesList.size()]);
    builder.setMultiChoiceItems(entries, checkedEntryIndexes,
            new OnMultiChoiceClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which,
                                    boolean isChecked) {
                    if (enableToggle) {
                        if (which == 0) {
                            ListView list = ((AlertDialog) dialog).getListView();
                            for (int i = 1; i < list.getCount(); i++) {
                                list.setItemChecked(i, isChecked);
                                checkedEntryIndexes[i] = isChecked;
                            }
                            return;
                        }
                    }
                    checkedEntryIndexes[which] = isChecked;
                }
            });
}
 
Example 6
Project: boohee_v5.6   File: AlertDialog.java   View source code 5 votes vote down vote up
public Builder setMultiChoiceItems(int itemsId, boolean[] checkedItems, OnMultiChoiceClickListener listener) {
    this.P.mItems = this.P.mContext.getResources().getTextArray(itemsId);
    this.P.mOnCheckboxClickListener = listener;
    this.P.mCheckedItems = checkedItems;
    this.P.mIsMultiChoice = true;
    return this;
}
 
Example 7
Project: boohee_v5.6   File: AlertDialog.java   View source code 5 votes vote down vote up
public Builder setMultiChoiceItems(CharSequence[] items, boolean[] checkedItems, OnMultiChoiceClickListener listener) {
    this.P.mItems = items;
    this.P.mOnCheckboxClickListener = listener;
    this.P.mCheckedItems = checkedItems;
    this.P.mIsMultiChoice = true;
    return this;
}
 
Example 8
Project: boohee_v5.6   File: AlertDialog.java   View source code 5 votes vote down vote up
public Builder setMultiChoiceItems(Cursor cursor, String isCheckedColumn, String labelColumn, OnMultiChoiceClickListener listener) {
    this.P.mCursor = cursor;
    this.P.mOnCheckboxClickListener = listener;
    this.P.mIsCheckedColumn = isCheckedColumn;
    this.P.mLabelColumn = labelColumn;
    this.P.mIsMultiChoice = true;
    return this;
}
 
Example 9
Project: learnforandroidfragAS   File: lib.java   View source code 5 votes vote down vote up
public static yesnoundefined ShowMessageYesNoWithCheckboxes(Context context,
                                                            String msg,
                                                            CharSequence[] items,
                                                            boolean[] checkedItems,
                                                            DialogInterface.OnMultiChoiceClickListener cbListener)
{
    // System.Threading.SynchronizationContext.Current.Post(new
    // System.Threading.SendOrPostCallback(DelShowException),new
    // ExStateInfo(context, ex));

    try
    {
        if (YesNoHandler == null)
        {
            YesNoHandler = new Handler()
            {
                @Override
                public void handleMessage(Message mesg)
                {
                    //throw new MessageException();
                }
            };
        }

        DialogResultYes = yesnoundefined.undefined;
        AlertDialog.Builder A = new AlertDialog.Builder(context);
        A.setPositiveButton(context.getString(R.string.yes), listenerYesNo);
        A.setNegativeButton(context.getString(R.string.no), listenerYesNo);
        //A.setMessage(msg);
        A.setTitle(msg);
        A.setMultiChoiceItems(items, checkedItems, cbListener);
        AlertDialog dlg = A.create();
        dlg.setOnDismissListener(new DialogInterface.OnDismissListener()
        {
 
Example 10
Project: haxsync   File: MultiSelectListPreference.java   View source code 5 votes vote down vote up
@Override
protected void onPrepareDialogBuilder(Builder builder) {
	builder.setMultiChoiceItems(getEntries(), checkedEntryIndexes,
			new OnMultiChoiceClickListener() {

				@Override
				public void onClick(DialogInterface dialog, int which,
						boolean isChecked) {
					checkedEntryIndexes[which] = isChecked;
				}
			});
}
 
Example 11
Project: androzic-library   File: MultiSelectListPreference.java   View source code 5 votes vote down vote up
@Override
protected void onPrepareDialogBuilder(Builder builder) {
	updateCheckedEntryIndexes();
	builder.setMultiChoiceItems(getEntries(), checkedEntryIndexes,
			new OnMultiChoiceClickListener() {

				@Override
				public void onClick(DialogInterface dialog, int which,
						boolean isChecked) {
					checkedEntryIndexes[which] = isChecked;
				}
			});
}
 
Example 12
Project: PhotoPhase   File: MultiSelectListPreferenceCompat.java   View source code 5 votes vote down vote up
@Override
public android.app.AlertDialog.Builder setMultiChoiceItems(
        CharSequence[] items, boolean[] checkedItems, OnMultiChoiceClickListener listener) {
    mItems = items;
    mCheckedItems = checkedItems;
    mOnMultiChoiceClickListener = listener;
    return this;
}
 
Example 13
Project: MaterialPreference   File: PreferenceDialogBuilder.java   View source code 4 votes vote down vote up
public PreferenceDialogBuilder setMultiChoiceItems(int itemsId, boolean[] checkedItems, OnMultiChoiceClickListener listener) {
    mBuilder.setMultiChoiceItems(itemsId, checkedItems, listener);
    return this;
}
 
Example 14
Project: MaterialPreference   File: PreferenceDialogBuilder.java   View source code 4 votes vote down vote up
public PreferenceDialogBuilder setMultiChoiceItems(CharSequence[] items, boolean[] checkedItems, OnMultiChoiceClickListener listener) {
    mBuilder.setMultiChoiceItems(items, checkedItems, listener);
    return this;
}
 
Example 15
Project: MaterialPreference   File: PreferenceDialogBuilder.java   View source code 4 votes vote down vote up
public PreferenceDialogBuilder setMultiChoiceItems(Cursor cursor, String isCheckedColumn, String labelColumn, OnMultiChoiceClickListener listener) {
    mBuilder.setMultiChoiceItems(cursor, isCheckedColumn, labelColumn, listener);
    return this;
}
 
Example 16
Project: MaterialPreference   File: PreferenceDialogBuilder.java   View source code 4 votes vote down vote up
public PreferenceDialogBuilder setMultiChoiceItems(int itemsId, boolean[] checkedItems, OnMultiChoiceClickListener listener) {
    mBuilder.setMultiChoiceItems(itemsId, checkedItems, listener);
    return this;
}
 
Example 17
Project: MaterialPreference   File: PreferenceDialogBuilder.java   View source code 4 votes vote down vote up
public PreferenceDialogBuilder setMultiChoiceItems(CharSequence[] items, boolean[] checkedItems, OnMultiChoiceClickListener listener) {
    mBuilder.setMultiChoiceItems(items, checkedItems, listener);
    return this;
}
 
Example 18
Project: MaterialPreference   File: PreferenceDialogBuilder.java   View source code 4 votes vote down vote up
public PreferenceDialogBuilder setMultiChoiceItems(Cursor cursor, String isCheckedColumn, String labelColumn, OnMultiChoiceClickListener listener) {
    mBuilder.setMultiChoiceItems(cursor, isCheckedColumn, labelColumn, listener);
    return this;
}
 
Example 19
Project: AndroidMaterialDialog   File: OnMultiChoiceClickListenerWrapper.java   View source code 3 votes vote down vote up
/**
 * Creates a new wrapper, which implements the interface {@link OnItemClickListener} in order to
 * delegate the method calls to encapsulated listener of the type {@link
 * OnMultiChoiceClickListener}.
 *
 * @param listener
 *         The listener, which should be encapsulated by the wrapper, as an instance of the type
 *         {@link OnMultiChoiceClickListener} or null, if no listener should be encapsulated
 * @param dialog
 *         The dialog, the listener should belong to, as an instance of the type {@link
 *         ValidateableDialog}. The dialog may not be null
 * @param buttonType
 *         The type of the button or list item, the listener belongs to, as an {@link Integer}
 *         value
 */

public OnMultiChoiceClickListenerWrapper(@Nullable final OnMultiChoiceClickListener listener,
                                         @NonNull final ValidateableDialog dialog,
                                         final int buttonType) {
    super(dialog, buttonType);
    this.wrappedListener = listener;
}