android.widget.CheckedTextView#setChecked ( )源码实例Demo

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

源代码1 项目: edslite   文件: SingleChoiceDialog.java
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;
        }
    };
}
 
源代码2 项目: Androzic   文件: ImageArrayAdapter.java
/**
 * {@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;
}
 
源代码3 项目: OPFIab   文件: TrivialActivity.java
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);
}
 
源代码4 项目: android_maplibui   文件: TrackView.java
@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));
}
 
源代码5 项目: a   文件: IconListPreference.java
@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;
}
 
源代码6 项目: android-places-demos   文件: FieldSelector.java
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);
  }
}
 
源代码7 项目: android-places-demos   文件: FieldSelector.java
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);
  }
}
 
源代码8 项目: tysq-android   文件: RewardArticleDialog.java
/**
 * 将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);

}
 
源代码9 项目: EdXposedManager   文件: IconListPreference.java
@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;
}
 
源代码10 项目: MyBookshelf   文件: IconListPreference.java
@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;
}
 
源代码11 项目: android-ringtone-picker   文件: MainActivity.java
@Override
public void onClick(View v) {
    if (v instanceof CheckedTextView) {
        CheckedTextView checkedTextView = (CheckedTextView) v;
        checkedTextView.setChecked(!checkedTextView.isChecked());
    }
}
 
源代码12 项目: Toutiao   文件: IconListPreference.java
@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;
}
 
源代码13 项目: droidddle   文件: ThemeListPreference.java
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;
}
 
源代码14 项目: pybbsMD   文件: MainActivity.java
/**
 * 主导航项单击事件
 */
@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();
}
 
源代码15 项目: tuxguitar   文件: TGMainDrawerTrackListAdapter.java
@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;
}
 
源代码16 项目: 365browser   文件: PassphraseTypeDialogFragment.java
@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;
}
 
源代码17 项目: Identiconizer   文件: ContactsListActivity.java
@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();
}
 
源代码18 项目: Huochexing12306   文件: AuthPageAty.java
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;
}
 
源代码19 项目: Huochexing12306   文件: AuthPageAty.java
public void unregisterThirdPartyAccount(Platform plat, CheckedTextView ctvName) {
	plat.removeAccount();
	ctvName.setChecked(false);
	ctvName.setText(R.string.not_yet_authorized);
}
 
源代码20 项目: android-test   文件: ViewMatchersTest.java
@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));
}