本文整理了Java中android.widget.CheckBox
类的一些代码示例,展示了CheckBox
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CheckBox
类的具体详情如下:
包路径:android.widget.CheckBox
类名称:CheckBox
暂无
代码示例来源:origin: stackoverflow.com
public View newView(Context context, Cursor cur, ViewGroup parent) {
LayoutInflater li = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
return li.inflate(R.layout.mylist, parent, false);
TextView tvListText = (TextView)view.findViewById(R.id.list_text);
CheckBox cbListCheck = (CheckBox)view.findViewById(R.id.list_checkbox);
tvListText.setText(cur.getString(cur.getColumnIndex(Datenbank.DB_NAME)));
cbListCheck.setChecked((cur.getInt(cur.getColumnIndex(Datenbank.DB_STATE))==0? false:true))));
代码示例来源:origin: stackoverflow.com
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inView = inflater.inflate(R.layout.your_layout_file, null);
final CheckBox cBox = (CheckBox) inView.findViewById(R.id.bcheck); // your
cBox.setOnClickListener(new OnClickListener() {
CheckBox cb = (CheckBox) v.findViewById(R.id.your_checkbox_id);
if (cb.isChecked()) {
itemChecked.set(pos, true);
} else if (!cb.isChecked()) {
itemChecked.set(pos, false);
cBox.setChecked(itemChecked.get(pos)); // this will Check or Uncheck the
代码示例来源:origin: commonsguy/cw-omnibus
RowController(ChoiceCapableAdapter adapter, View row) {
super(row);
this.adapter=adapter;
label=(TextView)row.findViewById(R.id.label);
size=(TextView)row.findViewById(R.id.size);
icon=(ImageView)row.findViewById(R.id.icon);
cb=(CheckBox)row.findViewById(R.id.cb);
template=size.getContext().getString(R.string.size_template);
row.setOnClickListener(this);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
row.setOnTouchListener(new View.OnTouchListener() {
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public boolean onTouch(View v, MotionEvent event) {
v
.findViewById(R.id.row_content)
.getBackground()
.setHotspot(event.getX(), event.getY());
return(false);
}
});
}
cb.setOnCheckedChangeListener(this);
}
代码示例来源:origin: stackoverflow.com
protected void onListItemClick(ListView l, View v, int position, long id) {
Toast.makeText(getApplicationContext(), "You have selected item no."
+(position+1)+"", Toast.LENGTH_SHORT).show();
super.onListItemClick(l, v, position, id);
if (v != null) {
CheckBox checkBox = (CheckBox)v.findViewById(R.id.Checkbox);
checkBox.setChecked(!checkBox.isChecked());
}
}
代码示例来源:origin: facebook/facebook-android-sdk
@Override
void updateCheckboxState(CheckBox checkBox, boolean graphObjectSelected) {
checkBox.setChecked(graphObjectSelected);
int visible = (graphObjectSelected || selectionStrategy.shouldShowCheckBoxIfUnselected())
? View.VISIBLE : View.GONE;
checkBox.setVisibility(visible);
}
}
代码示例来源:origin: TeamNewPipe/NewPipe
private void setupSkipSilenceControl(@NonNull View rootView) {
skipSilenceCheckbox = rootView.findViewById(R.id.skipSilenceCheckbox);
if (skipSilenceCheckbox != null) {
skipSilenceCheckbox.setChecked(initialSkipSilence);
skipSilenceCheckbox.setOnCheckedChangeListener((compoundButton, isChecked) ->
setCurrentPlaybackParameters());
}
}
代码示例来源:origin: CarGuo/GSYVideoPlayer
public void init() {
LayoutInflater inflater = LayoutInflater.from(context);
View view = inflater.inflate(R.layout.layout_custom_dialog, null);
setContentView(view);
txtTitle = (TextView) view.findViewById(R.id.dialog_input_title);
editMessage = (EditText) view.findViewById(R.id.dialog_input_dialog_edit);
btnPostive = (TextView) view.findViewById(R.id.dialog_input_dialog_postive);
btnNegative = (TextView) view.findViewById(R.id.dialog_input_dialog_negative);
cacheCheck = (CheckBox) view.findViewById(R.id.dialog_input_check);
cacheCheck.setChecked(cache);
btnPostive.setVisibility(View.VISIBLE);
} else {
btnPostive.setVisibility(View.GONE);
btnNegative.setVisibility(View.VISIBLE);
} else {
btnNegative.setVisibility(View.GONE);
代码示例来源:origin: chrisk44/Hijacker
@Override
public View onCreateView(LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState){
fragmentView = inflater.inflate(R.layout.custom_action_editor, container, false);
titleView = fragmentView.findViewById(R.id.title);
startCmdView = fragmentView.findViewById(R.id.start_cmd);
stopCmdView = fragmentView.findViewById(R.id.stop_cmd);
processNameView = fragmentView.findViewById(R.id.process_name);
requirement_cb = fragmentView.findViewById(R.id.requirement);
has_process_name_cb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked){
save_btn.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view){
代码示例来源:origin: seven332/EhViewer
@SuppressLint("InflateParams")
public CheckBoxDialogBuilder(Context context, String message, String checkText, boolean checked) {
super(context);
View view = LayoutInflater.from(getContext()).inflate(R.layout.dialog_checkbox_builder, null);
setView(view);
TextView messageView = (TextView) view.findViewById(R.id.message);
mCheckBox = (CheckBox) view.findViewById(R.id.checkbox);
messageView.setText(message);
mCheckBox.setText(checkText);
mCheckBox.setChecked(checked);
}
代码示例来源:origin: stackoverflow.com
select.setOnClickListener(new OnClickListener()
while (phones.moveToNext())
String name=phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
String phoneNumber = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
System.out.println(".................."+phoneNumber);
vi = mInflater.inflate(R.layout.row, null);
TextView tv= (TextView) vi.findViewById(R.id.textView1);
tv1= (TextView) vi.findViewById(R.id.textView2);
cb = (CheckBox) vi.findViewById(R.id.checkBox1);
tv.setText("Name :"+ name1.get(position));
tv1.setText("Phone No :"+ phno1.get(position));
cb.setTag(position);
cb.setChecked(mCheckStates.get(position, false));
cb.setOnCheckedChangeListener(this);
代码示例来源:origin: stackoverflow.com
btnSelect.setOnClickListener(new OnClickListener() {
if (convertView == null) {
holder = new ViewHolder();
convertView = mInflater.inflate(R.layout.custom_gallery_item, null);
holder.imgThumb = (ImageView) convertView.findViewById(R.id.imgThumb);
holder.chkImage = (CheckBox) convertView.findViewById(R.id.chkImage);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
int id = cb.getId();
if (thumbnailsselection[id]) {
cb.setChecked(false);
thumbnailsselection[id] = false;
} else {
cb.setChecked(true);
thumbnailsselection[id] = true;
代码示例来源:origin: wdullaer/MaterialDateTimePicker
now.get(Calendar.HOUR_OF_DAY),
now.get(Calendar.MINUTE),
mode24Hours.isChecked()
).show();
});
now.get(Calendar.HOUR_OF_DAY),
now.get(Calendar.MINUTE),
mode24Hours.isChecked()
);
} else {
now.get(Calendar.MINUTE),
now.get(Calendar.SECOND),
mode24Hours.isChecked()
);
tpd.setThemeDark(modeDarkTime.isChecked());
tpd.vibrate(vibrateTime.isChecked());
tpd.dismissOnPause(dismissTime.isChecked());
tpd.enableSeconds(enableSeconds.isChecked());
tpd.setVersion(showVersion2.isChecked() ? TimePickerDialog.Version.VERSION_2 : TimePickerDialog.Version.VERSION_1);
if (modeCustomAccentTime.isChecked()) {
tpd.setAccentColor(Color.parseColor("#9C27B0"));
if (titleTime.isChecked()) {
tpd.setTitle("TimePicker Title");
if (limitSelectableTimes.isChecked()) {
代码示例来源:origin: k9mail/k-9
View layout = mDialog.getLayoutInflater().inflate(R.layout.accounts_password_prompt, scrollView);
TextView incomingText = layout.findViewById(R.id.password_prompt_incoming_server);
incomingText.setText(activity.getString(R.string.settings_import_incoming_server,
incoming.host));
mIncomingPasswordView = layout.findViewById(R.id.incoming_server_password);
mIncomingPasswordView.addTextChangedListener(this);
} else {
TextView outgoingText = layout.findViewById(R.id.password_prompt_outgoing_server);
outgoingText.setText(activity.getString(R.string.settings_import_outgoing_server,
outgoing.host));
mUseIncomingView.setChecked(true);
mUseIncomingView.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mUseIncomingView.setChecked(false);
mUseIncomingView.setVisibility(View.GONE);
mOutgoingPasswordView.setEnabled(true);
mUseIncomingView.setChecked(mUseIncoming);
代码示例来源:origin: stackoverflow.com
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = convertView;
if(view == null){
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.row_layout, null);
}
TextView textView = (TextView) view.findViewById(R.id.title);
textView.setText(values[position]);
CheckBox box = (CheckBox) view.findViewById(R.id.chk);
box.setTag(position);
box.setOnCheckedChangeListener(this);
box.setChecked(checkedStatus[position]);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// on each click change the state of checkbox
box.setChecked(!box.isChecked());
}
});
return view;
}
代码示例来源:origin: facebook/facebook-android-sdk
if (null == convertView) {
convertView = getActivity().getLayoutInflater()
.inflate(R.layout.list_item_user, parent, false);
convertView.setBackgroundColor(Color.argb(50, 255, 255, 255));
ProfilePictureView profilePic = (ProfilePictureView) convertView.findViewById(
R.id.slotPic);
if (userId != null) {
TextView userNameTextView = (TextView) convertView.findViewById(
R.id.slotUserName);
userNameTextView.setText(userName);
final CheckBox currentUserCheckBox = (CheckBox) convertView.findViewById(
R.id.currentUserIndicator);
currentUserCheckBox.setChecked(
slotManager.getSelectedSlot() == slot
&& slot.getUserInfo() != null);
currentUserCheckBox.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
currentUserCheckBox.setEnabled(slot.getAccessToken() != null);
代码示例来源:origin: stackoverflow.com
planet.toggleChecked();
ContactViewHolder viewHolder = (ContactViewHolder) item
.getTag();
viewHolder.getCheckBox().setChecked(planet.isChecked());
mCursor.moveToFirst();
contact_read = new Contact[mCursor.getCount()];
do {
contact_read[j] = new Contact(mCursor.getString(mCursor
.getColumnIndex(Contacts.DISPLAY_NAME)));
j++;
convertView = inflater.inflate(R.layout.simplerow, null);
.findViewById(R.id.rowTextView);
checkBox = (CheckBox) convertView.findViewById(R.id.CheckBox01);
checkBox.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
CheckBox cb = (CheckBox) v;
Contact contact = (Contact) cb.getTag();
contact.setChecked(cb.isChecked());
代码示例来源:origin: aa112901/remusic
MusicInfo model = mList.get(i);
((ListItemViewHolder) holder).mainTitle.setText(model.musicName);
((ListItemViewHolder) holder).title.setText(model.artist);
((ListItemViewHolder) holder).checkBox.setChecked(isItemChecked(i));
((ListItemViewHolder) holder).checkBox.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
((ListItemViewHolder) holder).itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
代码示例来源:origin: stackoverflow.com
LayoutInflater mInflater = (LayoutInflater)
mContext.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
convertView = mInflater.inflate(R.layout.category_filter_item, null);
ImageView filter_img = (ImageView) convertView.findViewById(R.id.category_picture);
TextView filter_category = (TextView) convertView.findViewById(R.id.filter_category);
CheckBox checkBox = (CheckBox) convertView.findViewById(R.id.checkbox);
checkBox .setOnClickListener(new View.OnClickListener() {
if (checkBox.isChecked())
Toast.makeText(view.getContext(), "TEST", Toast.LENGTH_SHORT).show();
filter_category.setTypeface(DroidSans);
filter_category.setText(mFilters.get(position));
filter_img.setBackgroundResource(mPictures.get(position));
代码示例来源:origin: ankidroid/Anki-Android
private void bindView(final int position, final View v) {
View[] columns = (View[]) v.getTag();
final Map<String, String> dataSet = getCards().get(position);
final int colorIdx = getColor(dataSet.get(mColorFlagKey));
col.setText(dataSet.get(mFromKeys[i]));
v.setBackgroundColor(backgroundColor);
final CheckBox checkBox = (CheckBox) v.findViewById(R.id.card_checkbox);
checkBox.setVisibility(View.VISIBLE);
if (mCheckedCardPositions.contains(position)) {
checkBox.setChecked(true);
} else {
checkBox.setChecked(false);
checkBox.jumpDrawablesToCurrentState();
} else {
checkBox.setChecked(false);
checkBox.setVisibility(View.GONE);
checkBox.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
代码示例来源:origin: wangdan/AisenWeiBo
@Override
protected void layoutInit(LayoutInflater inflater, Bundle savedInstanceState) {
super.layoutInit(inflater, savedInstanceState);
btnOverflow.setVisibility(View.GONE);
editContent.setHint(R.string.publish_cmt_def);
StatusContent status = getPublishBean().getStatusContent();
txtContent.setText(AisenUtils.getCommentText(status.getText()));
if (status.getUser() != null)
BitmapLoader.getInstance().display(this, AisenUtils.getUserPhoto(status.getUser()), imgPhoto, ImageConfigUtils.getLargePhotoConfig());
checkBox.setChecked(Boolean.parseBoolean(getPublishBean().getExtras().getParameter("forward")));
checkBox.setOnCheckedChangeListener(this);
((BaseActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);
((BaseActivity) getActivity()).getSupportActionBar().setTitle(R.string.title_cmt_status);
}
内容来源于网络,如有侵权,请联系作者删除!