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

The following examples show how to use android.widget.CheckBox#setClickable() . 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: SettingView.java    From Popeens-DSub with GNU General Public License v3.0 6 votes vote down vote up
public SettingView(Context context) {
	super(context, false);
	this.context = context;
	LayoutInflater.from(context).inflate(R.layout.basic_choice_item, this, true);

	titleView = (TextView) findViewById(R.id.item_name);
	checkBox = (CheckBox) findViewById(R.id.item_checkbox);
	checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
		@Override
		public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
			if(item != null) {
				item.setValue(isChecked);
			}
		}
	});
	checkBox.setClickable(false);
}
 
Example 2
Source File: DialogMenu.java    From Dashchan with Apache License 2.0 5 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
	ListItem listItem = getItem(position);
	ViewHolder viewHolder;
	if (convertView == null) {
		viewHolder = new ViewHolder();
		View view = LayoutInflater.from(parent.getContext()).inflate(layoutResId, parent, false);
		if (listItem.checkable) {
			LinearLayout linearLayout = new LinearLayout(parent.getContext());
			linearLayout.setOrientation(LinearLayout.HORIZONTAL);
			linearLayout.setGravity(Gravity.CENTER_VERTICAL);
			linearLayout.addView(view, new LinearLayout.LayoutParams(0,
					LinearLayout.LayoutParams.WRAP_CONTENT, 1f));
			CheckBox checkBox = new CheckBox(parent.getContext());
			checkBox.setClickable(false);
			checkBox.setFocusable(false);
			int paddingRight = view.getPaddingRight() - (int) (4f * ResourceUtils.obtainDensity(view));
			checkBox.setPadding(checkBox.getPaddingLeft(), checkBox.getPaddingTop(),
					Math.max(checkBox.getPaddingRight(), paddingRight), checkBox.getPaddingBottom());
			linearLayout.addView(checkBox, LinearLayout.LayoutParams.WRAP_CONTENT,
					LinearLayout.LayoutParams.WRAP_CONTENT);
			viewHolder.checkBox = checkBox;
			view = linearLayout;
		}
		viewHolder.textView = view.findViewById(android.R.id.text1);
		view.setTag(viewHolder);
		convertView = view;
	} else {
		viewHolder = (ViewHolder) convertView.getTag();
	}
	viewHolder.textView.setText(listItem.title);
	if (listItem.checkable) {
		viewHolder.checkBox.setChecked(listItem.checked);
	}
	return convertView;
}
 
Example 3
Source File: ModeSelectListItemView.java    From android-openslmediaplayer with Apache License 2.0 5 votes vote down vote up
@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    mTextView = (TextView) findViewById(android.R.id.text1);
    mCheckBox = (CheckBox) findViewById(android.R.id.checkbox);

    mCheckBox.setClickable(false);
    mCheckBox.setFocusable(false);
}
 
Example 4
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 5
Source File: DConnectServiceListActivity.java    From DeviceConnect-Android with MIT License 4 votes vote down vote up
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.item_device_connect_service, null);
    }

    final ServiceContainer service = getItem(position);
    convertView.setTag(service);

    convertView.setBackgroundResource(service.isOnline() ?
        R.color.service_list_item_background_online :
        R.color.service_list_item_background_offline);

    TextView statusView = (TextView) convertView.findViewById(R.id.service_online_status);
    statusView.setText(service.isOnline() ?
        R.string.device_connect_service_is_online :
        R.string.device_connect_service_is_offline);

    TextView nameView = (TextView) convertView.findViewById(R.id.service_name);
    nameView.setText(service.getName());

    CheckBox checkBox =
        (CheckBox) convertView.findViewById(R.id.device_connect_service_removal_checkbox);
    checkBox.setVisibility(mHasCheckbox && !service.isOnline() ? View.VISIBLE : View.GONE);
    checkBox.setOnCheckedChangeListener(null);
    if (!service.isOnline()) {
        checkBox.setEnabled(true);
        checkBox.setClickable(true);
        checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(final CompoundButton buttonView,
                                         final boolean isChecked) {
                setChecked(service, isChecked);
            }
        });
        if (isChecked(service)) {
            checkBox.setChecked(true);
        } else {
            checkBox.setChecked(false);
        }
    } else {
        checkBox.setEnabled(false);
        checkBox.setClickable(false);
        checkBox.setChecked(false);
    }


    return convertView;
}