Java Code Examples for android.widget.CheckedTextView#setChecked()

The following examples show how to use android.widget.CheckedTextView#setChecked() . 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: TrackView.java    From android_maplibui with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void bindView(View view, Context context, Cursor cursor) {

    final Integer id = cursor.getInt(0);
    final ImageView visibility = (ImageView) view.findViewById(R.id.iv_visibility);
    visibility.setImageDrawable(cursor.getInt(2) != 0 ? mVisibilityOn : mVisibilityOff);
    visibility.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            boolean isVisible = visibility.getDrawable().equals(mVisibilityOn);
            updateRecord(id, !isVisible);
        }
    });

    CheckedTextView name = (CheckedTextView) view.findViewById(R.id.tv_name);
    name.setChecked(mSelectedIds.contains(id + ""));
    name.setText(cursor.getString(1));
}
 
Example 2
Source File: SingleChoiceDialog.java    From edslite with GNU General Public License v2.0 6 votes vote down vote up
protected ArrayAdapter<T> initAdapter(List<T> items)
{
    return new ArrayAdapter<T>(getActivity(), android.R.layout.simple_list_item_single_choice, items)
    {
        @Override
        public View getView(final int position, View convertView, ViewGroup parent)
        {
            final CheckedTextView tv = (CheckedTextView) super.getView(position, convertView, parent);
            tv.setOnClickListener(v ->
            {
                getListView().setItemChecked(position, true);
                _okButton.setEnabled(true);
            });
            tv.setChecked(getListView().isItemChecked(position));
            return tv;
        }
    };
}
 
Example 3
Source File: TrivialActivity.java    From OPFIab with Apache License 2.0 6 votes vote down vote up
public HeaderViewHolder(final DragSortAdapter<?> dragSortAdapter, final View itemView) {
    super(dragSortAdapter, itemView);
    spinHelper = (Spinner) itemView.findViewById(R.id.spin_helper);
    tvSetupStatus = (TextView) itemView.findViewById(R.id.tv_setup_status);
    tvSetupProvider = (TextView) itemView.findViewById(R.id.tv_setup_provider);
    pbSetup = (ProgressBar) itemView.findViewById(R.id.pb_setup);
    btnForget = (Button) itemView.findViewById(R.id.btn_forget);
    btnInit = (Button) itemView.findViewById(R.id.btn_init);
    btnSetup = (Button) itemView.findViewById(R.id.btn_setup);
    ctvAutoRecover = (CheckedTextView) itemView.findViewById(R.id.ctv_auto_recover);

    final HelpersAdapter adapter = new HelpersAdapter();
    spinHelper.setAdapter(adapter);
    spinHelper.setSelection(adapter.getPosition(TrivialBilling.getHelper()));
    spinHelper.setOnItemSelectedListener(this);

    btnForget.setOnClickListener(this);
    btnInit.setOnClickListener(this);
    btnSetup.setOnClickListener(this);
    ctvAutoRecover.setChecked(TrivialBilling.isAutoRecover());
    ctvAutoRecover.setOnClickListener(this);

    iabHelper.addSetupListener(this);
}
 
Example 4
Source File: ImageArrayAdapter.java    From Androzic with GNU General Public License v3.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public View getView(int position, View convertView, ViewGroup parent)
{
	LayoutInflater inflater = ((Activity) getContext()).getLayoutInflater();
	View row = inflater.inflate(R.layout.imagemultichoicelistitem, parent, false);

	ImageView imageView = (ImageView) row.findViewById(R.id.image);
	imageView.setImageResource(resourceIds[position]);

	CheckedTextView checkedTextView = (CheckedTextView) row.findViewById(R.id.check);

	checkedTextView.setText(getItem(position));

	if (position == index)
	{
		checkedTextView.setChecked(true);
	}
	return row;
}
 
Example 5
Source File: PassphraseTypeDialogFragment.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    CheckedTextView view = (CheckedTextView) super.getView(position, convertView, parent);
    PassphraseType positionType = getType(position);
    PassphraseType currentType = getCurrentTypeFromArguments();
    Set<PassphraseType> allowedTypes =
            currentType.getAllowedTypes(getIsEncryptEverythingAllowedFromArguments());

    // Set the item to checked it if it is the currently selected encryption type.
    view.setChecked(positionType == currentType);
    // Allow user to click on enabled types for the current type.
    view.setEnabled(allowedTypes.contains(positionType));
    return view;
}
 
Example 6
Source File: IconListPreference.java    From a with GNU General Public License v3.0 5 votes vote down vote up
@Override
@SuppressLint("ViewHolder")
public View getView(int position, View convertView, ViewGroup parent) {
    LayoutInflater inflater = ((Activity) getContext()).getLayoutInflater();
    View view = inflater.inflate(R.layout.item_icon_preference, parent, false);
    CheckedTextView textView = (CheckedTextView) view.findViewById(R.id.label);
    textView.setText(getItem(position));
    textView.setChecked(position == mSelectedIndex);

    ImageView imageView = (ImageView) view.findViewById(R.id.icon);
    imageView.setImageDrawable(mImageDrawables.get(position));
    return view;
}
 
Example 7
Source File: TGMainDrawerTrackListAdapter.java    From tuxguitar with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
	TGMainDrawerTrackListItem item = (TGMainDrawerTrackListItem) this.getItem(position);
	
	View view = (convertView != null ? convertView : getLayoutInflater().inflate(R.layout.view_main_drawer_check_item, parent, false));
	view.setOnClickListener(getMainDrawer().getActionHandler().createGoToTrackAction(item.getTrack()));
	view.setOnLongClickListener(getMainDrawer().getActionHandler().createGoToTrackWithSmartMenuAction(item.getTrack()));

	CheckedTextView checkedTextView = (CheckedTextView) view.findViewById(R.id.main_drawer_check_item);
	checkedTextView.setText(item.getLabel());
	checkedTextView.setChecked(Boolean.TRUE.equals(item.getSelected()));
	
	return view;
}
 
Example 8
Source File: MainActivity.java    From pybbsMD with Apache License 2.0 5 votes vote down vote up
/**
 * 主导航项单击事件
 */
@OnClick({
        cn.tomoya.android.md.R.id.btn_nav_all,
        cn.tomoya.android.md.R.id.btn_nav_good,
        cn.tomoya.android.md.R.id.btn_nav_share,
        cn.tomoya.android.md.R.id.btn_nav_ask,
        cn.tomoya.android.md.R.id.btn_nav_pybbs
})
public void onNavigationMainItemClick(CheckedTextView itemView) {
    for (CheckedTextView navItem : navMainItemList) {
        navItem.setChecked(navItem.getId() == itemView.getId());
    }
    drawerLayout.closeDrawers();
}
 
Example 9
Source File: ThemeListPreference.java    From droidddle with Apache License 2.0 5 votes vote down vote up
public View getView(final int position, View convertView, ViewGroup parent) {
    View row = convertView;

    if (row == null) {
        row = mInflater.inflate(android.R.layout.simple_list_item_single_choice, parent, false);
    }
    CheckedTextView tv = (CheckedTextView) row.findViewById(android.R.id.text1);
    tv.setText(getItem(position).toString());
    tv.setChecked(mEntryIndex == position);
    tv.setTextColor(Color.parseColor(colors[position]));
    return row;
}
 
Example 10
Source File: IconListPreference.java    From Toutiao with Apache License 2.0 5 votes vote down vote up
@NonNull
@Override
@SuppressLint("ViewHolder")
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
    LayoutInflater inflater = ((BaseActivity) getContext()).getLayoutInflater();
    View view = inflater.inflate(R.layout.item_icon_listpreference, parent, false);

    CheckedTextView textView = view.findViewById(R.id.label);
    textView.setText(getItem(position));
    textView.setChecked(position == selectedIndex);

    ImageView imageView = view.findViewById(R.id.icon);
    imageView.setImageDrawable(list.get(position));
    return view;
}
 
Example 11
Source File: MainActivity.java    From android-ringtone-picker with Apache License 2.0 5 votes vote down vote up
@Override
public void onClick(View v) {
    if (v instanceof CheckedTextView) {
        CheckedTextView checkedTextView = (CheckedTextView) v;
        checkedTextView.setChecked(!checkedTextView.isChecked());
    }
}
 
Example 12
Source File: IconListPreference.java    From MyBookshelf with GNU General Public License v3.0 5 votes vote down vote up
@NotNull
@Override
@SuppressLint("ViewHolder")
public View getView(int position, View convertView, ViewGroup parent) {
    LayoutInflater inflater = ((Activity) getContext()).getLayoutInflater();
    View view = inflater.inflate(R.layout.item_icon_preference, parent, false);
    CheckedTextView textView = view.findViewById(R.id.label);
    textView.setText(getItem(position));
    textView.setChecked(position == mSelectedIndex);

    ImageView imageView = view.findViewById(R.id.icon);
    imageView.setImageDrawable(mImageDrawables.get(position));
    return view;
}
 
Example 13
Source File: IconListPreference.java    From EdXposedManager with GNU General Public License v3.0 5 votes vote down vote up
@NonNull
@Override
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
    LayoutInflater inflater = ((Activity) getContext()).getLayoutInflater();
    @SuppressLint("ViewHolder") View view = inflater.inflate(R.layout.icon_preference_item, parent, false);
    CheckedTextView textView = view.findViewById(R.id.label);
    textView.setText(getItem(position));
    textView.setChecked(position == mSelectedIndex);

    ImageView imageView = view.findViewById(R.id.icon);
    imageView.setImageDrawable(mImageDrawables.get(position));
    return view;
}
 
Example 14
Source File: RewardArticleDialog.java    From tysq-android with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 将textview设置为未选中状态
 */
private void setCheckedStatus(CheckedTextView textView,
							CheckedTextView textView1,
							CheckedTextView textView2,
							CheckedTextView textView3,
							CheckedTextView textView4,
							LinearLayout linearLayout,
							LinearLayout linearLayout1,
							LinearLayout linearLayout2,
							LinearLayout linearLayout3,
							LinearLayout linearLayout4,
							int rewardNum){

		textView1.setChecked(false);
		textView2.setChecked(false);
		textView3.setChecked(false);
		textView4.setChecked(false);

		setRewardCoinUnSelectedColor(linearLayout1, textView1);
		setRewardCoinUnSelectedColor(linearLayout2, textView2);
		setRewardCoinUnSelectedColor(linearLayout3, textView3);
		setRewardCoinUnSelectedColor(linearLayout4, textView4);

		textView.toggle();
		if (textView.isChecked()){
				mRewardNum = rewardNum;
				setRewardCoinSelectedColor(linearLayout, textView);
		}else {
				setRewardCoinUnSelectedColor(linearLayout, textView);
				mRewardNum = 0;
		}

		Log.d("RewardArticleDialog", String.valueOf(textView.isChecked()) + rewardNum);

}
 
Example 15
Source File: FieldSelector.java    From android-places-demos with Apache License 2.0 5 votes vote down vote up
private static void updateView(View view, State state) {
  if (view instanceof CheckedTextView) {
    CheckedTextView checkedTextView = (CheckedTextView) view;
    checkedTextView.setText(state.field.toString());
    checkedTextView.setChecked(state.checked);
  }
}
 
Example 16
Source File: FieldSelector.java    From android-places-demos with Apache License 2.0 5 votes vote down vote up
private static void updateView(View view, State state) {
  if (view instanceof CheckedTextView) {
    CheckedTextView checkedTextView = (CheckedTextView) view;
    checkedTextView.setText(state.field.toString());
    checkedTextView.setChecked(state.checked);
  }
}
 
Example 17
Source File: AuthPageAty.java    From Huochexing12306 with Apache License 2.0 4 votes vote down vote up
public void unregisterThirdPartyAccount(Platform plat, CheckedTextView ctvName) {
	plat.removeAccount();
	ctvName.setChecked(false);
	ctvName.setText(R.string.not_yet_authorized);
}
 
Example 18
Source File: AuthPageAty.java    From Huochexing12306 with Apache License 2.0 4 votes vote down vote up
public View getView(int position, View convertView, ViewGroup parent) {
	if (convertView == null) {
		convertView = View.inflate(context, R.layout.auth_page_item, null);
	}

	int count = getCount();
	View llItem = convertView.findViewById(R.id.llItem);
	int dp_10 = cn.sharesdk.framework.utils.R.dipToPx(parent.getContext(), 10);
	if (count == 1) {
		llItem.setBackgroundResource(R.drawable.list_item_single_normal);
		llItem.setPadding(0, 0, 0, 0);
		convertView.setPadding(dp_10, dp_10, dp_10, dp_10);
	}
	else if (position == 0) {
		llItem.setBackgroundResource(R.drawable.list_item_first_normal);
		llItem.setPadding(0, 0, 0, 0);
		convertView.setPadding(dp_10, dp_10, dp_10, 0);
	}
	else if (position == count - 1) {
		llItem.setBackgroundResource(R.drawable.list_item_last_normal);
		llItem.setPadding(0, 0, 0, 0);
		convertView.setPadding(dp_10, 0, dp_10, dp_10);
	}
	else {
		llItem.setBackgroundResource(R.drawable.list_item_middle_normal);
		llItem.setPadding(0, 0, 0, 0);
		convertView.setPadding(dp_10, 0, dp_10, 0);
	}

	Platform plat = getItem(position);
	ImageView ivLogo = (ImageView) convertView.findViewById(R.id.ivLogo);
	Bitmap logo = getIcon(plat);
	if (logo != null && !logo.isRecycled()) {
		ivLogo.setImageBitmap(logo);
	}
	CheckedTextView ctvName = (CheckedTextView) convertView.findViewById(R.id.ctvName);
	ctvName.setChecked(plat.isValid());
	if (plat.isValid()) {
		String userName = plat.getDb().get("nickname");
		if (userName == null || userName.length() <= 0 || "null".equals(userName)) {
			userName = getName(plat);
		}
		ctvName.setText(userName);
	} else {
		ctvName.setText(R.string.not_yet_authorized);
	}
	return convertView;
}
 
Example 19
Source File: ViewMatchersTest.java    From android-test with Apache License 2.0 4 votes vote down vote up
@UiThreadTest
@Test
public void checkBoxMatchers() {
  assertFalse(isChecked().matches(new Spinner(context)));
  assertFalse(isNotChecked().matches(new Spinner(context)));

  CheckBox checkBox = new CheckBox(context);
  checkBox.setChecked(true);
  assertTrue(isChecked().matches(checkBox));
  assertFalse(isNotChecked().matches(checkBox));

  checkBox.setChecked(false);
  assertFalse(isChecked().matches(checkBox));
  assertTrue(isNotChecked().matches(checkBox));

  RadioButton radioButton = new RadioButton(context);
  radioButton.setChecked(false);
  assertFalse(isChecked().matches(radioButton));
  assertTrue(isNotChecked().matches(radioButton));

  radioButton.setChecked(true);
  assertTrue(isChecked().matches(radioButton));
  assertFalse(isNotChecked().matches(radioButton));

  CheckedTextView checkedText = new CheckedTextView(context);
  checkedText.setChecked(false);
  assertFalse(isChecked().matches(checkedText));
  assertTrue(isNotChecked().matches(checkedText));

  checkedText.setChecked(true);
  assertTrue(isChecked().matches(checkedText));
  assertFalse(isNotChecked().matches(checkedText));

  Checkable checkable =
      new Checkable() {
        @Override
        public boolean isChecked() {
          return true;
        }

        @Override
        public void setChecked(boolean ignored) {}

        @Override
        public void toggle() {}
      };

  assertFalse(isChecked().matches(checkable));
  assertFalse(isNotChecked().matches(checkable));
}
 
Example 20
Source File: ContactsListActivity.java    From Identiconizer with Apache License 2.0 4 votes vote down vote up
@Override
public void onBindViewHolder(ViewHolder viewHolder, Cursor cursor) {
    MyListItem myListItem = MyListItem.fromCursor(cursor);

    CheckedTextView contactName = viewHolder.mCheckedTextView;
    contactName.setText(myListItem.getName());
    contactName.setChecked(checkedItems.contains(myListItem.getPosition()));
    final ImageView contactImage = viewHolder.mImageView;
    int photoThumbnailURIIndex = cursor.getColumnIndexOrThrow(ContactsContract.Contacts.PHOTO_THUMBNAIL_URI);
    String photoThumbnailString = cursor.getString(photoThumbnailURIIndex);
    contactImage.setImageResource(R.drawable.ic_identicons_style_retro);
    if (photoThumbnailString == null)
        return;

    final Uri photoThumbnailURI = Uri.parse(photoThumbnailString);
    new Thread(new Runnable() {
        public void run() {
            try {
                // Original implementation from: http://stackoverflow.com/a/6228188
                // Create a 48 dip thumbnail
                InputStream input = getContentResolver().openInputStream(photoThumbnailURI);

                BitmapFactory.Options onlyBoundsOptions = new BitmapFactory.Options();
                onlyBoundsOptions.inJustDecodeBounds = true;
                onlyBoundsOptions.inDither = true;
                onlyBoundsOptions.inPreferredConfig = Bitmap.Config.ARGB_8888;
                BitmapFactory.decodeStream(input, null, onlyBoundsOptions);
                input.close();

                int originalSize = (onlyBoundsOptions.outHeight > onlyBoundsOptions.outWidth) ? onlyBoundsOptions.outHeight : onlyBoundsOptions.outWidth;
                Resources r = getResources();
                float thumbnailSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 48, r.getDisplayMetrics());
                double ratio = (originalSize > thumbnailSize) ? (originalSize / thumbnailSize) : 1.0;

                BitmapFactory.Options bitmapOptions = new BitmapFactory.Options();
                bitmapOptions.inSampleSize = Integer.highestOneBit((int) Math.floor(ratio));
                bitmapOptions.inDither = true;
                bitmapOptions.inPreferredConfig = Bitmap.Config.ARGB_8888;
                input = getContentResolver().openInputStream(photoThumbnailURI);
                final Bitmap bitmap = BitmapFactory.decodeStream(input, null, bitmapOptions);
                input.close();

                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        contactImage.setImageBitmap(bitmap);
                    }
                });
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }).start();
}