Java Code Examples for android.widget.CheckBox#setTag()

The following examples show how to use android.widget.CheckBox#setTag() . 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: UserSelectActivity.java    From WeChatMomentStat-Android with GNU General Public License v3.0 6 votes vote down vote up
protected void loadUserList() {
    LinearLayout userListContainer = (LinearLayout)findViewById(R.id.user_list_container);
    ArrayList<UserSnsInfo> userSnsList = Share.snsData.userSnsList;
    checkBoxList.clear();
    userListContainer.removeAllViews();
    for (int i=0;i<userSnsList.size();i++) {
        CheckBox userCheckBox = new CheckBox(this);
        userCheckBox.setText(userSnsList.get(i).userName + "(" + userSnsList.get(i).userId + ")" + "(" + String.format(getString(R.string.user_moment_count), userSnsList.get(i).snsList.size()) + ")");
        userListContainer.addView(userCheckBox);
        LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)userCheckBox.getLayoutParams();
        layoutParams.setMargins(5, 5, 5, 5);
        userCheckBox.setLayoutParams(layoutParams);
        userCheckBox.setChecked(true);
        userCheckBox.setTag(userSnsList.get(i).userId);
        checkBoxList.add(userCheckBox);
    }
}
 
Example 2
Source File: AddOrEditBookFragment.java    From barterli_android with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the references to the barter type checkboxes, set the tags to simplify building the tags
 * array when sending the request to server
 *
 * @param view The content view of the fragment
 */
private void initBarterTypeCheckBoxes(final View view) {
    mBarterCheckBox = (CheckBox) view.findViewById(R.id.checkbox_barter);
    mSellCheckBox = (CheckBox) view.findViewById(R.id.checkbox_sell);
    mLendCheckBox = (CheckBox) view.findViewById(R.id.checkbox_lend);

    // Set the barter tags
    mBarterCheckBox.setTag(R.string.tag_barter_type, BarterType.BARTER);
    mSellCheckBox.setTag(R.string.tag_barter_type, BarterType.SALE);
    mLendCheckBox.setTag(R.string.tag_barter_type, BarterType.LEND);

    mSellCheckBox.setOnCheckedChangeListener(this);

    mBarterTypeCheckBoxes = new CheckBox[3];
    mBarterTypeCheckBoxes[0] = mBarterCheckBox;
    mBarterTypeCheckBoxes[1] = mSellCheckBox;
    mBarterTypeCheckBoxes[2] = mLendCheckBox;
}
 
Example 3
Source File: MapFragment.java    From blocktopograph with GNU Affero General Public License v3.0 6 votes vote down vote up
@NonNull
@Override
public View getView(final int position, View v, @NonNull ViewGroup parent) {

    final NamedBitmapChoice m = getItem(position);
    if(m == null) return new RelativeLayout(getContext());

    if (v == null) v = LayoutInflater
                .from(getContext())
                .inflate(R.layout.img_name_check_list_entry, parent, false);


    ImageView img = (ImageView) v.findViewById(R.id.entry_img);
    TextView text = (TextView) v.findViewById(R.id.entry_text);
    final CheckBox check = (CheckBox) v.findViewById(R.id.entry_check);

    img.setImageBitmap(m.namedBitmap.getNamedBitmapProvider().getBitmap());
    text.setText(m.namedBitmap.getNamedBitmapProvider().getBitmapDisplayName());
    check.setTag(position);
    check.setChecked(m.enabledTemp);
    check.setOnCheckedChangeListener(changeListener);

    return v;
}
 
Example 4
Source File: StockAdapter.java    From StickyItemDecoration with Apache License 2.0 6 votes vote down vote up
@Override
public void bindData(RecyclerViewHolder holder, int viewType, int position, StockEntity.StockInfo item) {
    int type = holder.getItemViewType();
    switch (type) {

        case TYPE_STICKY_HEAD:

            CheckBox checkBox = holder.getCheckBox(R.id.checkbox);
            checkBox.setTag(position);
            checkBox.setOnCheckedChangeListener(this);
            checkBox.setChecked(item.check);

            holder.setText(R.id.tv_stock_name, item.stickyHeadName);

            break;

        case TYPE_DATA:
            setData(holder, item);
            break;
        case TYPE_SMALL_STICKY_HEAD_WITH_DATA:
            setData(holder, item);
            holder.setText(R.id.tv_stock_name, item.stickyHeadName);
            break;

    }
}
 
Example 5
Source File: ExcludePathsActivity.java    From Camera-Roll-Android-App with Apache License 2.0 5 votes vote down vote up
@Override
public void setFile(File_POJO file) {
    super.setFile(file);
    CheckBox checkBox = itemView.findViewById(R.id.checkbox);
    checkBox.setTag(file.getPath());
    setOnCheckedChangeListener(null);
    checkBox.setChecked(file.excluded);
    ArrayList<String> excludedPaths = Provider.getExcludedPaths();
    boolean enabled = !Provider.isDirExcludedBecauseParentDirIsExcluded(
            file.getPath(), excludedPaths);
    checkBox.setEnabled(enabled);
}
 
Example 6
Source File: SignInFragment.java    From line-sdk-android with Apache License 2.0 5 votes vote down vote up
private void buildScopeCheckBoxes() {
    final List<Scope> scopes = (BuildConfig.INCLUDE_INTERNAL_API_TEST) ?
            Arrays.asList(
                    Scope.PROFILE,
                    Scope.OPENID_CONNECT,
                    Scope.OC_EMAIL,
                    Scope.OC_PHONE_NUMBER,
                    Scope.OC_GENDER,
                    Scope.OC_BIRTHDATE,
                    Scope.OC_ADDRESS,
                    Scope.OC_REAL_NAME,
                    Scope.FRIEND,
                    Scope.GROUP,
                    Scope.MESSAGE,
                    Scope.ONE_TIME_SHARE,
                    Scope.OPEN_CHAT_TERM_STATUS,
                    Scope.OPEN_CHAT_ROOM_CREATE_JOIN,
                    Scope.OPEN_CHAT_SUBSCRIPTION_INFO
            ) :
            Arrays.asList(
                    Scope.PROFILE,
                    Scope.OPENID_CONNECT,
                    new Scope("self_defined_scope")
            );


    final FragmentActivity activity = getActivity();
    for (final Scope scope : scopes) {
        final CheckBox checkBox = new CheckBox(activity);
        checkBox.setText(scope.getCode());
        checkBox.setTag(scope);

        scopeCheckboxLayout.addView(checkBox);

        scopeCheckBoxes.add(checkBox);
    }
}
 
Example 7
Source File: MultiChoiceAdapterHelperBase.java    From MultiChoiceAdapter with Apache License 2.0 5 votes vote down vote up
private void initItemCheckbox(int position, ViewGroup view) {
    CheckBox checkBox = (CheckBox) view.findViewById(android.R.id.checkbox);
    boolean checked = isChecked(position);
    checkBox.setTag(position);
    checkBox.setChecked(checked);
    checkBox.setOnCheckedChangeListener(this);
}
 
Example 8
Source File: ForumSelectListener.java    From hipda with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    if (holder instanceof ViewHolder) {
        CheckBox checkBox = ((ViewHolder) holder).cb_forum_enabled;
        checkBox.setText(mForumSelctions.get(position).mForum.getName());
        checkBox.setChecked(mForumSelctions.get(position).mEnabled);
        checkBox.setTag(position);
        checkBox.setOnClickListener(mOnClickListener);
    }
}
 
Example 9
Source File: ContactRecyclerViewAdapter.java    From PowerSwitch_Android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onBindViewHolder(final ContactRecyclerViewAdapter.ViewHolder holder, int position) {
    final Contact contact = contacts.get(holder.getAdapterPosition());
    holder.name.setText(contact.getName());

    holder.numbers.removeAllViews();
    Iterator<String> iterator = contact.getPhoneNumbers().iterator();
    while (iterator.hasNext()) {
        final String number = iterator.next();

        LinearLayout linearLayout = new LinearLayout(context);
        linearLayout.setOrientation(LinearLayout.HORIZONTAL);
        CheckBox checkBox = new CheckBox(context);
        checkBox.setTag(number);

        checkBox.setOnTouchListener(checkBoxInteractionListener);
        checkBox.setOnCheckedChangeListener(checkBoxInteractionListener);

        TextView phoneNumber = new TextView(context);
        phoneNumber.setText(number);

        linearLayout.addView(checkBox);
        linearLayout.addView(phoneNumber);

        holder.numbers.addView(linearLayout);
    }

    if (holder.getAdapterPosition() == getItemCount() - 1) {
        holder.footer.setVisibility(View.VISIBLE);
    } else {
        holder.footer.setVisibility(View.GONE);
    }
}
 
Example 10
Source File: FileChooserDialog.java    From videocreator with Apache License 2.0 5 votes vote down vote up
private void initListItem(CommonHolder holder, FileProvider.FileData data, int position) {
    holder.setText(R.id.txt_path, data.name);
    holder.setItemOnClickListener(v -> {
        if (data.name.equals("../")) {
            selectIndex = -1;
            refreshData(mFileProvider.gotoParent());
        } else {
            selectIndex = -1;
            refreshData(mFileProvider.gotoChild(position));
        }
    });
    holder.setText(R.id.txt_info, data.info);
    if (data.isDir) {
        holder.setSrc(R.id.img_file, R.drawable.ic_wenjian);
        holder.setVisible(R.id.img_back, View.VISIBLE);
    } else {
        holder.setSrc(R.id.img_file, R.drawable.ic_file);
        holder.setVisible(R.id.img_back, View.GONE);
    }

    CheckBox checkBox = holder.getView(R.id.checkBox3);

    if (checkBox != null) {
        checkBox.setVisibility(data.selectable ? View.VISIBLE : View.GONE);
        checkBox.setTag(position);
        checkBox.setChecked(selectIndex == position);
        if (selectIndex == position) {
            weakCheckBox = new WeakReference<>(checkBox);
        }
        checkBox.setOnCheckedChangeListener(this);
    }
}
 
Example 11
Source File: PromptUpdateDialog.java    From smartcoins-wallet with MIT License 5 votes vote down vote up
@NonNull
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        LayoutInflater vi = (LayoutInflater) getContext().getSystemService(
                Context.LAYOUT_INFLATER_SERVICE);
        convertView = vi.inflate(R.layout.account_update_prompt_item, null);
        CheckBox checkbox = (CheckBox) convertView.findViewById(R.id.update);
        checkbox.setTag(new Integer(position));
        checkbox.setText(getItem(position).account_name);
        checkbox.setOnCheckedChangeListener(this);
    }
    return convertView;
}
 
Example 12
Source File: UserSelectActivity.java    From hayoou-wechat-export with GNU General Public License v3.0 5 votes vote down vote up
protected void loadUserList() {
    LinearLayout userListContainer = (LinearLayout)findViewById(R.id.user_list_container);
    //ArrayList<UserSnsInfo> userSnsList = Share.snsData.userSnsList;
    checkBoxList.clear();
    userListContainer.removeAllViews();
    //userSnsList.get(i).snsList.size();
    ArrayList<UserSnsInfo> snsSizeRank = Share.snsData.userSnsList;//new ArrayList<UserSnsInfo>(userSnsList);
    Collections.sort(snsSizeRank, new Comparator<UserSnsInfo>() {
        @Override
        public int compare(UserSnsInfo lhs, UserSnsInfo rhs) {
            if (rhs.snsList.size() - lhs.snsList.size() > 0) {
                return 1;
            } else if (rhs.snsList.size() - lhs.snsList.size() < 0) {
                return -1;
            } else {
                return 0;
            }
        }
    });

    UserSnsInfo userSnsInfo2=null;
    for (int i=0;i<snsSizeRank.size();i++) {
        userSnsInfo2 = snsSizeRank.get(i);
        CheckBox userCheckBox = new CheckBox(this);
        userCheckBox.setText(userSnsInfo2.authorName + "(" + userSnsInfo2.userId + ")" + "(" + String.format(getString(R.string.user_moment_count), userSnsInfo2.snsList.size()) + ")");
        userListContainer.addView(userCheckBox);
        LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)userCheckBox.getLayoutParams();
        layoutParams.setMargins(5, 5, 5, 5);
        userCheckBox.setLayoutParams(layoutParams);
        userCheckBox.setChecked(true);
        userCheckBox.setTag(userSnsInfo2.userId);
        checkBoxList.add(userCheckBox);
    }
}
 
Example 13
Source File: FileExpandableAdapter.java    From ShareBox with Apache License 2.0 5 votes vote down vote up
@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
    String f = (String) getChild(groupPosition, childPosition);
    FileExpandableInfo vh = (FileExpandableInfo) getGroup(groupPosition);
    if (convertView == null)
        convertView = LayoutInflater.from(mContext).inflate(R.layout.layout_file_item, parent, false);

    FileUtil.MediaFileType type = mTabHolder.getType();
    if (type == FileUtil.MediaFileType.APP && f.startsWith("/data/app") && mInstalledAppNames != null) {
        ((TextView) convertView.findViewById(R.id.text_name)).setText(mInstalledAppNames[childPosition]);
    } else {
        ((TextView) convertView.findViewById(R.id.text_name)).setText(FileUtil.INSTANCE.getFileName(f));
    }

    ImageView icon = (ImageView) convertView.findViewById(R.id.icon);
    icon.setImageDrawable(null);

    setChildViewThumb(type, f, icon);

    CheckBox check = (CheckBox) convertView.findViewById(R.id.check_box);
    check.setChecked(vh.isItemActivated(f));
    check.setTag(f);
    check.setTag(R.id.extra_tag, vh);
    check.setOnClickListener(mCheckOnClickListener);

    convertView.setTag(f);
    convertView.setOnClickListener(this);
    convertView.setOnLongClickListener(this);
    return convertView;
}
 
Example 14
Source File: ItemShoppingListCursorAdapter.java    From ShoppingList with MIT License 4 votes vote down vote up
@Override
public void bindView(View view, Context context, Cursor cursor) {
    ItemShoppingList itemShoppingList = getItem(cursor.getPosition());

    TextView tvId = (TextView) view.findViewById(R.id.idItemShoppingList);
    tvId.setText(String.valueOf(itemShoppingList.getId()));

    TextView tvDescription = (TextView) view.findViewById(R.id.descriptionItemShoppingList);
    tvDescription.setText(itemShoppingList.getDescription());


    if (UserPreferences.getShowCheckBox(context)) {
        tvDescription.setPaintFlags(itemShoppingList.isChecked() ? Paint.STRIKE_THRU_TEXT_FLAG : Paint.ANTI_ALIAS_FLAG);
        tvDescription.setTypeface(null, itemShoppingList.isChecked() ? Typeface.ITALIC : Typeface.NORMAL);
    }

    int leftPadding = UserPreferences.getShowCheckBox(context) ? tvDescription.getPaddingLeft() : 15;
    tvDescription.setPadding(leftPadding, tvDescription.getPaddingTop(), tvDescription.getPaddingRight(), tvDescription.getPaddingBottom());

    CheckBox cbChecked = (CheckBox) view.findViewById(R.id.checkedItemShoppingList);
    cbChecked.setOnCheckedChangeListener(null);
    cbChecked.setTag(itemShoppingList.getId());
    cbChecked.setChecked(itemShoppingList.isChecked());
    cbChecked.setClickable(!isSelected());
    cbChecked.setVisibility(UserPreferences.getShowCheckBox(context) ? View.VISIBLE : View.GONE);

    if (!isSelected()) {
        cbChecked.setOnCheckedChangeListener((OnCheckedChangeListener) context);
    }

    TextView tvQuantity = (TextView) view.findViewById(R.id.qtItemShoppingList);
    tvQuantity.setVisibility(UserPreferences.getShowQuantity(context) ? View.VISIBLE : View.GONE);
    tvQuantity.setText(CustomFloatFormat.getSimpleFormatedValue(itemShoppingList.getQuantity()));

    TextView tvUnitValue = (TextView) view.findViewById(R.id.unitValueItemShoppingList);
    tvUnitValue.setVisibility(UserPreferences.getShowUnitValue(context) ? View.VISIBLE : View.GONE);
    tvUnitValue.setText(CustomFloatFormat.getMonetaryMaskedValue(context, itemShoppingList.getUnitValue()));

    TextView tvTotal = (TextView) view.findViewById(R.id.totalItemShoppingList);
    tvTotal.setVisibility(itemShoppingList.getTotal() != 0 ? View.VISIBLE : View.GONE);
    tvTotal.setText(CustomFloatFormat.getMonetaryMaskedValue(context, itemShoppingList.getTotal()));

    view.setBackgroundColor(((isSelected()) && getIdSelected() == itemShoppingList.getId()) ? context.getResources().getColor(R.color.gray_inactive) : Color.TRANSPARENT);

}
 
Example 15
Source File: ConfigureApartmentDialogPage1NameFragment.java    From PowerSwitch_Android with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Generate Gateway items and add them to view
 */
private void addGatewaysToLayout() {
    String inflaterString = Context.LAYOUT_INFLATER_SERVICE;
    LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(inflaterString);

    try {
        List<Gateway> gateways = DatabaseHandler.getAllGateways();
        for (Gateway gateway : gateways) {
            @SuppressLint("InflateParams")
            LinearLayout gatewayLayout = (LinearLayout) inflater.inflate(R.layout.gateway_overview, null);
            // every inflated layout has to be added manually, attaching while inflating will only generate every
            // child one, but not for every gateway
            linearLayoutSelectableGateways.addView(gatewayLayout);

            final CheckBox checkBox = (CheckBox) gatewayLayout.findViewById(R.id.checkbox_use_gateway);
            checkBox.setTag(R.string.gateways, gateway);
            CheckBoxInteractionListener checkBoxInteractionListener = new CheckBoxInteractionListener() {
                @Override
                public void onCheckedChangedByUser(CompoundButton buttonView, boolean isChecked) {
                    notifyConfigurationChanged();
                }
            };
            checkBox.setOnTouchListener(checkBoxInteractionListener);
            checkBox.setOnCheckedChangeListener(checkBoxInteractionListener);
            gatewayCheckboxList.add(checkBox);

            gatewayLayout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    checkBox.setChecked(!checkBox.isChecked());
                    notifyConfigurationChanged();
                }
            });

            TextView gatewayName = (TextView) gatewayLayout.findViewById(R.id.textView_gatewayName);
            gatewayName.setText(gateway.getName());

            TextView gatewayType = (TextView) gatewayLayout.findViewById(R.id.textView_gatewayType);
            gatewayType.setText(gateway.getModel());

            TextView gatewayHost = (TextView) gatewayLayout.findViewById(R.id.textView_gatewayHost);
            gatewayHost.setText(String.format(Locale.getDefault(), "%s:%d", gateway.getLocalHost(), gateway.getLocalPort()));

            TextView gatewayDisabled = (TextView) gatewayLayout.findViewById(R.id.textView_disabled);
            if (gateway.isActive()) {
                gatewayDisabled.setVisibility(View.GONE);
            } else {
                gatewayDisabled.setVisibility(View.VISIBLE);
            }
        }
    } catch (Exception e) {
        StatusMessageHandler.showErrorMessage(getActivity(), e);
    }
}
 
Example 16
Source File: ConfigureSceneDialogPage1NameFragment.java    From PowerSwitch_Android with GNU General Public License v3.0 4 votes vote down vote up
private void addReceiversToLayout() {
    String inflaterString = Context.LAYOUT_INFLATER_SERVICE;
    LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(inflaterString);

    try {
        for (Room room : DatabaseHandler.getRooms(SmartphonePreferencesHandler.getCurrentApartmentId())) {
            LinearLayout roomLayout = new LinearLayout(getActivity());
            roomLayout.setOrientation(LinearLayout.VERTICAL);
            roomLayout.setPadding(0, 8, 0, 8);
            linearLayout_selectableReceivers.addView(roomLayout);

            TextView roomName = new TextView(getActivity());
            roomName.setText(room.getName());
            roomName.setTextColor(ThemeHelper.getThemeAttrColor(getActivity(), android.R.attr.textColorPrimary));
            roomLayout.addView(roomName);

            for (Receiver receiver : room.getReceivers()) {
                LinearLayout receiverLayout = new LinearLayout(getActivity());
                receiverLayout.setOrientation(LinearLayout.HORIZONTAL);
                roomLayout.addView(receiverLayout);

                final CheckBox checkBox = (CheckBox) inflater.inflate(R.layout.simple_checkbox, receiverLayout, false);
                checkBox.setTag(R.string.room, room);
                checkBox.setTag(R.string.receiver, receiver);
                receiverLayout.addView(checkBox);
                checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                    @Override
                    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                        checkValidity();
                    }
                });
                receiverCheckboxList.add(checkBox);

                TextView textView_receiverName = new TextView(getActivity());
                textView_receiverName.setText(receiver.getName());
                receiverLayout.addView(textView_receiverName);

                receiverLayout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        checkBox.setChecked(!checkBox.isChecked());
                    }
                });
            }
        }
    } catch (Exception e) {
        StatusMessageHandler.showErrorMessage(getActivity(), e);
    }
}
 
Example 17
Source File: AlarmListAdapter.java    From SpecialAlarmClock with Apache License 2.0 4 votes vote down vote up
@Override
public View getView(int position, View view, ViewGroup viewGroup) {
    if (null == view)
        view = LayoutInflater.from(alarmActivity).inflate(R.layout.list_element, null);

    Alarm alarm = (Alarm) getItem(position);
    CheckBox checkBox = (CheckBox) view.findViewById(R.id.checkBox_alarm_active);
    checkBox.setChecked(alarm.IsAlarmActive());
    checkBox.setTag(position);
    checkBox.setOnClickListener(alarmActivity);

    TextView alarmTimeView = (TextView) view.findViewById(R.id.textView_alarm_time);
    alarmTimeView.setText(alarm.getAlarmTimeString());


    TextView alarmDaysView = (TextView) view.findViewById(R.id.textView_alarm_days);

    alarmDaysView.setText(alarm.getRepeatDaysString());


    return view;
}
 
Example 18
Source File: DaysOfWeekPreferenceAdapterX.java    From PhoneProfilesPlus with Apache License 2.0 4 votes vote down vote up
public View getView(int position, View convertView, ViewGroup parent)
{
    // day of week to display
    DayOfWeek calendar = daysOfWeekList.get(position);
    //System.out.println(String.valueOf(position));

    // The child views in each row.
    TextView textViewDisplayName;
    CheckBox checkBox;

    // Create a new row view
    if (convertView == null)
    {
        convertView = inflater.inflate(R.layout.days_of_week_preference_list_item, parent, false);

        // Find the child views.
        textViewDisplayName = convertView.findViewById(R.id.days_of_week_pref_dlg_item_display_name);
        checkBox = convertView.findViewById(R.id.days_of_week_pref_dlg_item_checkbox);

        // Optimization: Tag the row with it's child views, so we don't
        // have to
        // call findViewById() later when we reuse the row.
        convertView.setTag(new DayOfWeekViewHolder(textViewDisplayName, checkBox));

        // If CheckBox is toggled, update the Contact it is tagged with.
        checkBox.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                CheckBox cb = (CheckBox) v;
                DayOfWeek dayOfWeek = (DayOfWeek) cb.getTag();
                dayOfWeek.checked = cb.isChecked();
            }
        });
    }
    // Reuse existing row view
    else
    {
        // Because we use a ViewHolder, we avoid having to call
        // findViewById().
        DayOfWeekViewHolder viewHolder = (DayOfWeekViewHolder) convertView.getTag();
        textViewDisplayName = viewHolder.textViewDisplayName;
        checkBox = viewHolder.checkBox;
    }

    // Tag the CheckBox with the Contact it is displaying, so that we
    // can
    // access the Contact in onClick() when the CheckBox is toggled.
    checkBox.setTag(calendar);

    // Display Contact data
    textViewDisplayName.setText(calendar.name);

    checkBox.setChecked(calendar.checked);

    return convertView;

}
 
Example 19
Source File: AdapterActManage.java    From BigApp_Discuz_Android with Apache License 2.0 4 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = View.inflate(context, R.layout.adapter_act_player, null);
    }
    final CheckBox cb_item = com.youzu.clan.base.widget.ViewHolder.get(convertView, R.id.cb_item);
    TextView tv_name = com.youzu.clan.base.widget.ViewHolder.get(convertView, R.id.tv_name);
    TextView tv_time = com.youzu.clan.base.widget.ViewHolder.get(convertView, R.id.tv_time);
    TextView tv_status = com.youzu.clan.base.widget.ViewHolder.get(convertView, R.id.tv_status);
    TextView tv_desc = com.youzu.clan.base.widget.ViewHolder.get(convertView, R.id.tv_desc);
    TextView tv_more = com.youzu.clan.base.widget.ViewHolder.get(convertView, R.id.tv_more);
    View v_margin_bottom = com.youzu.clan.base.widget.ViewHolder.get(convertView, R.id.v_margin_bottom);

    cb_item.setTag(position);
    final ActPlayer child = (ActPlayer) getItem(position);
    if (child != null) {
        if (child.isChecked) {
            cb_item.setChecked(true);
        } else {
            cb_item.setChecked(false);
        }
        tv_name.setText(child.getUsername());
        tv_name.setTextColor(_themeColor);
        tv_time.setText(child.getDateline());

        if (child.getVerified().equals("1")) {
            //用户是否通过审核,0:等待审核,1:已通过审核,2:打回完善资料
            tv_status.setTextColor(_themeColor);
            tv_status.setText(R.string.z_act_manage_check_success);
        } else if (child.getVerified().equals("2")) {
            tv_status.setTextColor(context.getResources().getColor(R.color.z_txt_c_act_publish_step_n));
            tv_status.setText(R.string.z_act_manage_check_fail);
        } else {
            tv_status.setTextColor(context.getResources().getColor(R.color.z_txt_c_act_publish_step_n));
            tv_status.setText(R.string.z_act_manage_check_null);
        }

        if (child.mode == 0) {//没有更多
            tv_desc.setText(child.desc);
            tv_more.setVisibility(View.GONE);
            v_margin_bottom.setVisibility(View.VISIBLE);
        } else {
            tv_more.setVisibility(View.VISIBLE);
            v_margin_bottom.setVisibility(View.GONE);
        }
        if (child.mode == 1) {//有更多,收起状态
            tv_desc.setText(child.desc_short);
            tv_more.setText(R.string.z_act_manage_player_info_more);
        }
        if (child.mode == 2) {//有更多,展开状态
            tv_desc.setText(child.desc);
            tv_more.setText(R.string.z_act_manage_player_info_less);
        }

        tv_desc.setLinksClickable(true);
        tv_desc.setMovementMethod(LinkMovementMethod.getInstance());

        cb_item.setOnCheckedChangeListener(new MyOnCheckedChangeListener(cb_item, position));
        tv_more.setOnClickListener(new MyOnTvMoreClickListener(tv_desc, child));
    }
    return convertView;
}
 
Example 20
Source File: BlurBenchmarkFragment.java    From BlurTestAndroid with Apache License 2.0 4 votes vote down vote up
private CheckBox createAlgorithmCheckbox(EBlurAlgorithm algorithm, LayoutInflater inflater) {
    CheckBox cb = (CheckBox) inflater.inflate(R.layout.inc_algorithm_checkbox, null);
    cb.setText(algorithm.toString());
    cb.setTag(algorithm);
    return cb;
}