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

The following examples show how to use android.widget.CheckBox#getId() . 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: ODKTag.java    From OpenMapKitAndroid with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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, ";");
}
 
Example 2
Source File: DoctorPlanAdapter.java    From android-apps with MIT License 4 votes vote down vote up
@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();
//		}
		
	}