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


Java ListView.CHOICE_MODE_MULTIPLE属性代码示例

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


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

示例1: getIds

public ArrayMap<Integer, long[]> getIds() {
    ArrayMap<Integer, long[]> arrayMap = new ArrayMap<>();
    if (choiceMode == ListView.CHOICE_MODE_MULTIPLE) {
        for (Map.Entry<Integer, SparseBooleanArray> entry : multipleIds.entrySet()) {
            List<Integer> l = new ArrayList<>();
            SparseBooleanArray ids = entry.getValue();
            for (int i = 0; i < ids.size(); i++) {
                if (ids.valueAt(i)) {
                    l.add(ids.keyAt(i));
                }
            }
            long[] _ids = new long[l.size()];
            for (int i = 0; i < l.size(); i++) {
                _ids[i] = l.get(i);
            }
            arrayMap.put(entry.getKey(), _ids);
        }
    }
    return arrayMap;
}
 
开发者ID:abook23,项目名称:godlibrary,代码行数:20,代码来源:ExpandableListViewCheckAdapter.java

示例2: initView

private void initView() {
    if (mCheckMode == CheckMode.CHOICE_MODE_MULTIPLE) {
        listViewChoiceMode = ListView.CHOICE_MODE_MULTIPLE;
        checkBoxAll.setVisibility(View.VISIBLE);
        checkBoxAll.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                fragmentListView.checkAll(isCheckAll);
                isCheckAll = !isCheckAll;
            }
        });
    } else if (mCheckMode == CheckMode.CHOICE_MODE_SINGLE) {
        listViewChoiceMode = ListView.CHOICE_MODE_SINGLE;
        checkBoxAll.setVisibility(View.GONE);
    } else if (mCheckMode == CheckMode.CHOICE_MODE_NONE) {
        listViewChoiceMode = ListView.CHOICE_MODE_NONE;
        checkBoxAll.setVisibility(View.GONE);
        buttonOk.setVisibility(View.GONE);
    }

    fragmentListView = FragmentListView.newInstance(mData, listViewChoiceMode);
    fragmentListView.setListListener(this);

    FragmentTransaction ft = getChildFragmentManager().beginTransaction();
    ft.add(R.id.gb_df_fl, fragmentListView);
    ft.commit();
}
 
开发者ID:abook23,项目名称:godlibrary,代码行数:27,代码来源:DialogFragmentList.java

示例3: updateChildItem

public void updateChildItem(View view, int groupPosition, int childPosition) {

        HolderChild holderChild = (HolderChild) view.getTag();
        boolean checkBoxState = !holderChild.checkBox.isChecked();
        if (choiceMode == ListView.CHOICE_MODE_SINGLE) {
            singleId = childPosition;
            this.singleGroupPosition = groupPosition;
            int fp = expandableListView.getFirstVisiblePosition();
            int lp = expandableListView.getLastVisiblePosition();
            for (int i = 0; i < lp - fp; i++) {
                View v = expandableListView.getChildAt(i);
                if (v != null) {
                    Object holder = v.getTag();
                    if (holder instanceof HolderChild) {
                        HolderChild _holderChild = (HolderChild) holder;
                        _holderChild.radioButton.setChecked(false);
                    }
                }
            }
            holderChild.radioButton.setChecked(checkBoxState);

        } else if (choiceMode == ListView.CHOICE_MODE_MULTIPLE) {
            putMultipleIds(groupPosition, childPosition, checkBoxState);
            holderChild.checkBox.setChecked(checkBoxState);
        }

    }
 
开发者ID:abook23,项目名称:godlibrary,代码行数:27,代码来源:ExpandableListViewCheckAdapter.java

示例4: onAttachedToWindow

@Override
protected void onAttachedToWindow()
{
    super.onAttachedToWindow();
    
    // Check if there is a valid GUI element that can visualize the current
    // check-state.
    if (mCheckedTextView != null)
    {
        final ViewParent p = getParent();
        
        // Check if the parent of this list item is a ListView
        if (p instanceof ListView)
        {
            final int choiceMode = ((ListView) p).getChoiceMode();
            
            // Decide which check-state notation to visualize (check box,
            // radio button or none).
            switch (choiceMode)
            {
            case ListView.CHOICE_MODE_MULTIPLE:
                mCheckedTextView.setCheckMarkDrawable(mCheckDrawable);
                break;
            
            case ListView.CHOICE_MODE_SINGLE:
                mCheckedTextView.setCheckMarkDrawable(mRadioDrawable);
                break;
            
            default:
                mCheckedTextView.setCheckMarkDrawable(null);
                break;
            }
        }
    }
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:35,代码来源:CheckableRelativeLayout.java

示例5: getChildView

@Override
    public View getChildView(final int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
        HolderChild holderChild;
        if (convertView == null) {
            holderChild = new HolderChild();
            View v = View.inflate(context, R.layout.item_exp_child_check_01, null);
            holderChild.imageView = (ImageView) v.findViewById(R.id.imageView);
            holderChild.title = (TextView) v.findViewById(R.id.exp_title);
            holderChild.describe = (TextView) v.findViewById(R.id.describe);
            holderChild.time = (TextView) v.findViewById(R.id.exp_time);
            holderChild.checkBox = (CheckBox) v.findViewById(R.id.checkBox);
            holderChild.radioButton = (RadioButton) v.findViewById(R.id.exp_radioButton);
            holderChild.exp_child_linear_layout = (RelativeLayout) v.findViewById(R.id.exp_child_linear_layout);
            if (choiceMode == ListView.CHOICE_MODE_NONE) {
                holderChild.checkBox.setVisibility(View.GONE);
                holderChild.radioButton.setVisibility(View.GONE);
            } else if (choiceMode == ListView.CHOICE_MODE_MULTIPLE) {
                holderChild.checkBox.setVisibility(View.VISIBLE);
                holderChild.radioButton.setVisibility(View.GONE);
            } else if (choiceMode == ListView.CHOICE_MODE_SINGLE) {
                holderChild.checkBox.setVisibility(View.GONE);
                holderChild.radioButton.setVisibility(View.VISIBLE);
            }
            if (!childImage)
                holderChild.imageView.setVisibility(View.GONE);
            v.setTag(holderChild);
            convertView = v;
        } else {
            holderChild = (HolderChild) convertView.getTag();
        }


        ExpChildBean child = data.get(groupPosition).getChilds().get(childPosition);
        if (child.getImageUrl() instanceof String)
            imageLoader.bindBitmap((String) child.getImageUrl(), holderChild.imageView, 80, 80);
        if (child.getImageUrl() instanceof Integer)
            holderChild.imageView.setImageResource((Integer) child.getImageUrl());

//        if (expandableListView.getChoiceMode() != ListView.CHOICE_MODE_NONE)
//            holderChild.exp_child_linear_layout.setOnClickListener(new View.OnClickListener() {
//                @Override
//                public void onClick(View v) {
//                    updateChildItem(v, groupPosition, childPosition);
//                }
//            });

        holderChild.title.setText(child.getTitle());
        holderChild.describe.setText(child.getDescribe());
        holderChild.time.setText(child.getTime());
        if (choiceMode == ListView.CHOICE_MODE_MULTIPLE)
            holderChild.checkBox.setChecked(getCheckedItemPositions(groupPosition, childPosition));
        else if (choiceMode == ListView.CHOICE_MODE_SINGLE) {
            if (groupPosition == singleGroupPosition && singleId == childPosition)
                holderChild.radioButton.setChecked(true);
            else
                holderChild.radioButton.setChecked(false);
        } else {
            holderChild.checkBox.setChecked(false);
            holderChild.radioButton.setChecked(false);
        }
        return convertView;
    }
 
开发者ID:abook23,项目名称:godlibrary,代码行数:62,代码来源:ExpandableListViewCheckAdapter.java


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