下面列出了android.widget.CheckBox#getId ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public String getSemiColonDelimitedTagValues(String customValues) {
Set<String> values = new HashSet<>();
for (CheckBox cb : checkBoxes) {
if (cb.isChecked()) {
int id = cb.getId();
ODKTagItem item = buttonIdToODKTagItemHash.get(id);
if (item != null) {
values.add(item.getValue());
}
}
}
if (customValues != null) {
customValues = customValues.trim();
String[] customValuesArr = customValues.split(";");
if (customValuesArr.length > 0) {
for (int i = 0; i < customValuesArr.length; i++) {
String customVal = customValuesArr[i];
values.add(customVal);
}
}
}
return StringUtils.join(values, ";");
}
@Override
public void onClick(View view) {
CheckBox cbF = (CheckBox) view;
Doctor doctorF =(Doctor)cbF.getTag();
// LinearLayout llLayoutP = (LinearLayout) cbF.getParent(); // get Check box parent layout
// LinearLayout llLayoutPL = (LinearLayout) llLayoutP.getParent(); // get xml file parent layout
// LinearLayout llLayoutF = (LinearLayout) llLayoutPL.getChildAt(0); // get first linear layout of xml file
//
// TextView tvDoctorId = (TextView) llLayoutF.getChildAt(1);
String doctorId = doctorF.getCode(), freq = doctorF.getFrequency();
//Toast.makeText(context, doctorId + "", 500).show();
//if( DoctorCallPlanCheck.isDoctorAvailable(doctorId,freq) )
{
if(view instanceof CheckBox ){
CheckBox cb = (CheckBox) view;
Doctor doctor =(Doctor)cb.getTag();
if(cb.isChecked()){
if(cb.getId()==R.id.cbEvning){
doctor.setShift("1");
}else if(cb.getId()==R.id.cbMorning) {
doctor.setShift("0");
}
//Toast.makeText(context, doctor.getName() + "", 500).show();
doctor.setSelected(true);
LinearLayout llLayout = (LinearLayout) cb.getParent();
for(int i=0; i<((ViewGroup)llLayout).getChildCount(); ++i) {
View nextChild = ((ViewGroup)llLayout).getChildAt(i);
if(nextChild instanceof CheckBox && nextChild.getId()==cb.getId() ){
}else if (nextChild instanceof CheckBox && nextChild.getId()!=cb.getId() ){
CheckBox cb2=(CheckBox) nextChild;
cb2.setChecked(false);
}
}
}else{
doctor.setShift("EVENING");
doctor.setSelected(false);
}
}
}
// else
// {
// CheckBox cb = (CheckBox) view;
// Doctor doctor =(Doctor)cb.getTag();
// doctor.setSelected(false);
//
// LinearLayout llLayout = (LinearLayout) cb.getParent();
//
// for(int i=0; i<((ViewGroup)llLayout).getChildCount(); ++i) {
// View nextChild = ((ViewGroup)llLayout).getChildAt(i);
// if(nextChild instanceof CheckBox && nextChild.getId()==cb.getId() ){
// CheckBox cb2=(CheckBox) nextChild;
// cb2.setChecked(false);
// }else if (nextChild instanceof CheckBox && nextChild.getId()!=cb.getId() ){
// CheckBox cb2=(CheckBox) nextChild;
// cb2.setChecked(false);
//
// }
// }
//
// Toast.makeText(context, "You have already cross max plan/call limit", 700).show();
// }
}