android.content.DialogInterface#OnMultiChoiceClickListener ( )源码实例Demo

下面列出了android.content.DialogInterface#OnMultiChoiceClickListener ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@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();
}
 
@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);
}
 
源代码3 项目: Android-Next   文件: AlertDialogFragment.java
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;
}
 
源代码4 项目: Klyph   文件: AlertUtil.java
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();
}
 
源代码5 项目: Android-Next   文件: AlertDialogFragment.java
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;
}
 
源代码6 项目: Contacts   文件: AlertUtil.java
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();
}
 
@Override
public final void setMultiChoiceItems(@Nullable final CharSequence[] items,
                                      @Nullable final boolean[] checkedItems,
                                      @Nullable final DialogInterface.OnMultiChoiceClickListener listener) {
    setMultiChoiceItems(items, null, checkedItems, listener);
}
 
源代码8 项目: SmartPack-Kernel-Manager   文件: Dialog.java
@Override
public Dialog setMultiChoiceItems(Cursor cursor, String isCheckedColumn, String labelColumn, DialogInterface.OnMultiChoiceClickListener listener){
    return (Dialog) super.setMultiChoiceItems(cursor, isCheckedColumn, labelColumn, listener);
}
 
源代码9 项目: SmartPack-Kernel-Manager   文件: Dialog.java
@Override
public Dialog
setMultiChoiceItems(CharSequence[] items, boolean[] checkedItems, DialogInterface.OnMultiChoiceClickListener listener){
    return (Dialog) super.setMultiChoiceItems(items, checkedItems, listener);
}
 
源代码10 项目: MTweaks-KernelAdiutorMOD   文件: Dialog.java
@Override
public Dialog setMultiChoiceItems(int itemsId, boolean[] checkedItems, DialogInterface.OnMultiChoiceClickListener listener){
    return (Dialog) super.setMultiChoiceItems(itemsId, checkedItems, listener);
}
 
源代码11 项目: MTweaks-KernelAdiutorMOD   文件: Dialog.java
@Override
public Dialog setMultiChoiceItems(Cursor cursor, String isCheckedColumn, String labelColumn, DialogInterface.OnMultiChoiceClickListener listener){
    return (Dialog) super.setMultiChoiceItems(cursor, isCheckedColumn, labelColumn, listener);
}
 
源代码12 项目: CompatAlertDialog   文件: AlertDialog.java
Builder setMultiChoiceItems(CharSequence[] items, boolean[] checkedItems, final DialogInterface
.OnMultiChoiceClickListener listener);
 
源代码13 项目: CompatAlertDialog   文件: AlertDialog.java
@Override
public Builder setMultiChoiceItems(Cursor cursor, String isCheckedColumn, String labelColumn, final
DialogInterface.OnMultiChoiceClickListener listener) {
    builder.setMultiChoiceItems(cursor, isCheckedColumn, labelColumn, listener);
    return this;
}
 
源代码14 项目: CompatAlertDialog   文件: AlertDialog.java
public Builder setMultiChoiceItems(CharSequence[] items, boolean[] checkedItems, final
DialogInterface.OnMultiChoiceClickListener listener) {
    builder.setMultiChoiceItems(items, checkedItems, listener);
    return this;
}
 
/**
 * 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();
}
 
/**
 * 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();
}
 
/**
 * 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();
}
 
源代码18 项目: talk-android   文件: AlertDialogWrapper.java
/**
 * 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;
}
 
/**
 * 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);
 
/**
 * 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);