Java Code Examples for android.content.DialogInterface#OnMultiChoiceClickListener

The following examples show how to use android.content.DialogInterface#OnMultiChoiceClickListener . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ListDialogDecorator.java    From AndroidMaterialDialog with Apache License 2.0 6 votes vote down vote up
@Override
public final void setMultiChoiceItems(@Nullable final CharSequence[] items,
                                      @Nullable final int[] iconResourceIds,
                                      @Nullable final boolean[] checkedItems,
                                      @Nullable final DialogInterface.OnMultiChoiceClickListener listener) {
    Condition.INSTANCE.ensureTrue(checkedItems == null || items == null ||
            checkedItems.length == items.length, "Invalid number of checked items given");
    this.items = null;
    this.iconResourceIds = iconResourceIds;
    this.singleChoiceItems = null;
    this.multiChoiceItems = items;
    this.adapter = items != null ? new RecyclerViewAdapterWrapper<>(getContext(),
            new ArrayRecyclerViewAdapter(android.R.layout.simple_list_item_multiple_choice,
                    items, iconResourceIds), new MultipleChoiceMode()) : null;
    this.layoutManager = new LinearLayoutManager(getContext());
    this.singleChoiceListener = null;
    this.multiChoiceListener = items != null ? listener : null;

    if (this.adapter != null && checkedItems != null) {
        for (int i = 0; i < checkedItems.length; i++) {
            this.adapter.setItemChecked(i, checkedItems[i]);
        }
    }

    attachAdapter();
}
 
Example 2
Source File: ListDialogDecorator.java    From AndroidMaterialDialog with Apache License 2.0 5 votes vote down vote up
@Override
public final void setMultiChoiceItems(final int resourceId,
                                      @Nullable final int[] iconResourceIds,
                                      @Nullable final boolean[] checkedItems,
                                      @Nullable final DialogInterface.OnMultiChoiceClickListener listener) {
    setMultiChoiceItems(getContext().getResources().getTextArray(resourceId), iconResourceIds,
            checkedItems, listener);
}
 
Example 3
Source File: AlertDialogFragment.java    From Android-Next with Apache License 2.0 5 votes vote down vote up
public Builder setMultiChoiceItems(CharSequence[] items, boolean[] checkedItems,
                                   final DialogInterface.OnMultiChoiceClickListener listener) {
    mParams.mItems = items;
    mParams.mOnCheckboxClickListener = listener;
    mParams.mCheckedItems = checkedItems;
    mParams.mIsMultiChoice = true;
    return this;
}
 
Example 4
Source File: AlertUtil.java    From Contacts with MIT License 5 votes vote down vote up
public static AlertDialog showAlert(Context context, int title, int message, String[] items, boolean[] checkedItems, DialogInterface.OnMultiChoiceClickListener itemsListener,
		int positiveButton, OnClickListener positiveListener, int negativeButton, OnClickListener negativeListener)
{
	AlertDialog.Builder builder = new AlertDialog.Builder(context);

	if (title != NONE)
	{
		builder.setTitle(title);
	}

	if (message != NONE)
	{
		builder.setMessage(message);
	}
	
	builder.setMultiChoiceItems(items, checkedItems, itemsListener);

	if (positiveButton != NO_RESOURCE)
	{
		builder.setPositiveButton(positiveButton, positiveListener);
	}

	if (negativeButton != NO_RESOURCE)
	{
		builder.setNegativeButton(negativeButton, negativeListener);
	}

	return builder.show();
}
 
Example 5
Source File: AlertUtil.java    From Klyph with MIT License 5 votes vote down vote up
public static AlertDialog showAlert(Context context, int title, int message, String[] items, boolean[] checkedItems, DialogInterface.OnMultiChoiceClickListener itemsListener,
		int positiveButton, OnClickListener positiveListener, int negativeButton, OnClickListener negativeListener)
{
	AlertDialog.Builder builder = new AlertDialog.Builder(context);

	if (title != NONE)
	{
		builder.setTitle(title);
	}

	if (message != NONE)
	{
		builder.setMessage(message);
	}
	
	builder.setMultiChoiceItems(items, checkedItems, itemsListener);

	if (positiveButton != NO_RESOURCE)
	{
		builder.setPositiveButton(positiveButton, positiveListener);
	}

	if (negativeButton != NO_RESOURCE)
	{
		builder.setNegativeButton(negativeButton, negativeListener);
	}

	return builder.show();
}
 
Example 6
Source File: AlertDialogFragment.java    From Android-Next with Apache License 2.0 5 votes vote down vote up
public Builder setMultiChoiceItems(int itemsId, boolean[] checkedItems,
                                   final DialogInterface.OnMultiChoiceClickListener listener) {
    mParams.mItems = mContext.getResources().getTextArray(itemsId);
    mParams.mOnCheckboxClickListener = listener;
    mParams.mCheckedItems = checkedItems;
    mParams.mIsMultiChoice = true;
    return this;
}
 
Example 7
Source File: ListDialogDecorator.java    From AndroidMaterialDialog with Apache License 2.0 4 votes vote down vote up
@Override
public final void setMultiChoiceItems(@Nullable final CharSequence[] items,
                                      @Nullable final boolean[] checkedItems,
                                      @Nullable final DialogInterface.OnMultiChoiceClickListener listener) {
    setMultiChoiceItems(items, null, checkedItems, listener);
}
 
Example 8
Source File: Dialog.java    From SmartPack-Kernel-Manager with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Dialog setMultiChoiceItems(Cursor cursor, String isCheckedColumn, String labelColumn, DialogInterface.OnMultiChoiceClickListener listener){
    return (Dialog) super.setMultiChoiceItems(cursor, isCheckedColumn, labelColumn, listener);
}
 
Example 9
Source File: Dialog.java    From SmartPack-Kernel-Manager with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Dialog
setMultiChoiceItems(CharSequence[] items, boolean[] checkedItems, DialogInterface.OnMultiChoiceClickListener listener){
    return (Dialog) super.setMultiChoiceItems(items, checkedItems, listener);
}
 
Example 10
Source File: Dialog.java    From MTweaks-KernelAdiutorMOD with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Dialog setMultiChoiceItems(int itemsId, boolean[] checkedItems, DialogInterface.OnMultiChoiceClickListener listener){
    return (Dialog) super.setMultiChoiceItems(itemsId, checkedItems, listener);
}
 
Example 11
Source File: Dialog.java    From MTweaks-KernelAdiutorMOD with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Dialog setMultiChoiceItems(Cursor cursor, String isCheckedColumn, String labelColumn, DialogInterface.OnMultiChoiceClickListener listener){
    return (Dialog) super.setMultiChoiceItems(cursor, isCheckedColumn, labelColumn, listener);
}
 
Example 12
Source File: AlertDialog.java    From CompatAlertDialog with Apache License 2.0 4 votes vote down vote up
public Builder setMultiChoiceItems(CharSequence[] items, boolean[] checkedItems, final
DialogInterface.OnMultiChoiceClickListener listener) {
    builder.setMultiChoiceItems(items, checkedItems, listener);
    return this;
}
 
Example 13
Source File: AlertDialog.java    From CompatAlertDialog with Apache License 2.0 4 votes vote down vote up
Builder setMultiChoiceItems(CharSequence[] items, boolean[] checkedItems, final DialogInterface
.OnMultiChoiceClickListener listener);
 
Example 14
Source File: AlertDialog.java    From CompatAlertDialog with Apache License 2.0 4 votes vote down vote up
@Override
public Builder setMultiChoiceItems(Cursor cursor, String isCheckedColumn, String labelColumn, final
DialogInterface.OnMultiChoiceClickListener listener) {
    builder.setMultiChoiceItems(cursor, isCheckedColumn, labelColumn, listener);
    return this;
}
 
Example 15
Source File: AbstractListDialogBuilder.java    From AndroidMaterialDialog with Apache License 2.0 3 votes vote down vote up
/**
 * Sets the selectable items, which should be shown by the dialog, which is created by the
 * builder. Multiple items can be selected at once.
 * <p>
 * Note, that the attached listener is not stored using a dialog's
 * <code>onSaveInstanceState</code>-method, because it is not serializable. Therefore this
 * method must be called again after configuration changes, e.g when the orientation of the
 * device has changed, in order to re-register the listener.
 *
 * @param items
 *         The items, which should be set, as an array of the type {@link CharSequence}. The
 *         items may not be null
 * @param iconResourceIds
 *         An array, which contains the resource ids of the items' icons, as an {@link Integer}
 *         array or null, if no icons should be displayed
 * @param checkedItems
 *         An array, which contains, whether the items, which correspond to the corresponding
 *         indices, should be selected by default, or not, as a {@link Boolean} array or null,
 *         if no items should be selected by default
 * @param listener
 *         The listener, which should be notified, when an item is clicked, as an instance of
 *         the type {@link DialogInterface.OnClickListener} or null, if no listener should be
 *         notified
 * @return The builder, the method has been called upon, as an instance of the generic type
 * BuilderType
 */
public final BuilderType setMultiChoiceItems(@NonNull final CharSequence[] items,
                                             @Nullable final int[] iconResourceIds,
                                             @Nullable final boolean[] checkedItems,
                                             @Nullable final DialogInterface.OnMultiChoiceClickListener listener) {
    getProduct().setMultiChoiceItems(items, iconResourceIds, checkedItems, listener);
    return self();
}
 
Example 16
Source File: AbstractListDialogBuilder.java    From AndroidMaterialDialog with Apache License 2.0 3 votes vote down vote up
/**
 * Sets the selectable items, which should be shown by the dialog, which is created by the
 * builder. Multiple items can be selected at once.
 * <p>
 * Note, that the attached listener is not stored using a dialog's
 * <code>onSaveInstanceState</code>-method, because it is not serializable. Therefore this
 * method must be called again after configuration changes, e.g when the orientation of the
 * device has changed, in order to re-register the listener.
 *
 * @param items
 *         The items, which should be set, as an array of the type {@link CharSequence}. The
 *         items may not be null
 * @param checkedItems
 *         An array, which contains, whether the items, which correspond to the corresponding
 *         indices, should be selected by default, or not, as a {@link Boolean} array or null,
 *         if no items should be selected by default
 * @param listener
 *         The listener, which should be notified, when an item is clicked, as an instance of
 *         the type {@link DialogInterface.OnClickListener} or null, if no listener should be
 *         notified
 * @return The builder, the method has been called upon, as an instance of the generic type
 * BuilderType
 */
public final BuilderType setMultiChoiceItems(@NonNull final CharSequence[] items,
                                             @Nullable final boolean[] checkedItems,
                                             @Nullable final DialogInterface.OnMultiChoiceClickListener listener) {
    getProduct().setMultiChoiceItems(items, checkedItems, listener);
    return self();
}
 
Example 17
Source File: AbstractListDialogBuilder.java    From AndroidMaterialDialog with Apache License 2.0 3 votes vote down vote up
/**
 * Sets the adapter, which provides the selectable items, which should be shown by the dialog,
 * which is created by the builder. Multiple items can be selected at once.
 * <p>
 * Note, that the adapter and the attached listener are not stored using a dialog's
 * <code>onSaveInstanceState</code>-method, because they are not serializable. Therefore this
 * method must be called again after configuration changes, e.g when the orientation of the
 * device has changed, in order to re-set the adapter and re-register the listener.
 *
 * @param adapter
 *         The adapter, which should be set, as an instance of the type {@link ListAdapter}. The
 *         adapter may not be null
 * @param checkedItems
 *         An array, which contains, whether the items, which correspond to the corresponding
 *         indices, should be selected by default, or not, as a {@link Boolean} array or null,
 *         if no items should be selected by default
 * @param listener
 *         The listener, which should be notified, when an item is clicked, as an instance of
 *         the type {@link DialogInterface.OnMultiChoiceClickListener} or null, if no listener
 *         should be notified
 * @return The builder, the method has been called upon, as an instance of the generic type
 * BuilderType
 */
public final <VH extends RecyclerView.ViewHolder> BuilderType setMultiChoiceItems(
        @Nullable final RecyclerView.Adapter<VH> adapter,
        @Nullable final RecyclerView.LayoutManager layoutManager,
        @Nullable final boolean[] checkedItems,
        @Nullable final DialogInterface.OnMultiChoiceClickListener listener) {
    getProduct().setMultiChoiceItems(adapter, layoutManager, checkedItems, listener);
    return self();
}
 
Example 18
Source File: ListDialogDecorator.java    From AndroidMaterialDialog with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the selectable items, which should be shown by the dialog. Multiple items can be
 * selected at once.
 * <p>
 * Note, that the attached listener is not stored using a dialog's
 * <code>onSaveInstanceState</code>-method, because it is not serializable. Therefore this
 * method must be called again after configuration changes, e.g when the orientation of the
 * device has changed, in order to re-register the listener.
 *
 * @param items        The items, which should be set, as an array of the type {@link CharSequence} or null,
 *                     if no items should be shown by the dialog
 * @param checkedItems An array, which contains, whether the items, which correspond to the corresponding
 *                     indices, should be selected by default, or not, as a {@link Boolean} array or null,
 *                     if no items should be selected by default
 * @param listener     The listener, which should be notified, when an item is clicked, as an instance of
 *                     the type {@link DialogInterface.OnMultiChoiceClickListener} or null, if no listener
 *                     should be notified
 */
void setMultiChoiceItems(@Nullable CharSequence[] items, @Nullable boolean[] checkedItems,
                         @Nullable DialogInterface.OnMultiChoiceClickListener listener);
 
Example 19
Source File: ListDialogDecorator.java    From AndroidMaterialDialog with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the selectable items, which should be shown by the dialog. Multiple items can be
 * selected at once.
 * <p>
 * Note, that the attached listener is not stored using a dialog's
 * <code>onSaveInstanceState</code>-method, because it is not serializable. Therefore this
 * method must be called again after configuration changes, e.g when the orientation of the
 * device has changed, in order to re-register the listener.
 *
 * @param resourceId   The resource id of the items, which should be set, as an {@link Integer} value. The
 *                     resource id must correspond to a valid array resource
 * @param checkedItems An array, which contains, whether the items, which correspond to the corresponding
 *                     indices, should be selected by default, or not, as a {@link Boolean} array or null,
 *                     if no items should be selected by default
 * @param listener     The listener, which should be notified, when an item is clicked, as an instance of
 *                     the type {@link DialogInterface.OnMultiChoiceClickListener} or null, if no listener
 *                     should be notified
 */
void setMultiChoiceItems(@ArrayRes int resourceId, @Nullable boolean[] checkedItems,
                         @Nullable DialogInterface.OnMultiChoiceClickListener listener);
 
Example 20
Source File: AlertDialogWrapper.java    From talk-android with MIT License 2 votes vote down vote up
/**
 * Set a list of items to be displayed in the dialog as the content, you will be notified of the selected item via the supplied listener.
 *
 * @param items        the text of the items to be displayed in the list.
 * @param checkedItems specifies which items are checked. It should be null in which case no items are checked. If non null it must be exactly the same length as the array of items.
 * @param listener     notified when an item on the list is clicked. The dialog will not be dismissed when an item is clicked. It will only be dismissed if clicked on a button, if no buttons are supplied it's up to the user to dismiss the dialog.		 * @return
 * @return This
 */
public Builder setMultiChoiceItems(@NonNull String[] items, @Nullable final boolean[] checkedItems, final DialogInterface.OnMultiChoiceClickListener listener) {
    builder.items(items);
    setUpMultiChoiceCallback(checkedItems, listener);
    return this;
}