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

The following examples show how to use android.widget.CheckBox#getTag() . 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: EditGameOptionsDialog.java    From PretendYoureXyzzyAndroid with GNU General Public License v3.0 6 votes vote down vote up
private void updateDecksCount() {
    int count = 0;
    int black = 0;
    int white = 0;
    for (int i = 0; i < decks.getChildCount(); i++) {
        CheckBox view = (CheckBox) decks.getChildAt(i);
        if (view.isChecked()) {
            Deck deck = (Deck) view.getTag();
            count++;
            black += deck.blackCards;
            white += deck.whiteCards;
        }
    }

    decksTitle.setText(String.format("%s (%s)", getString(R.string.cardSetsLabel), Utils.buildDeckCountString(count, black, white)));
}
 
Example 2
Source File: ConfigureApartmentDialogPage1NameFragment.java    From PowerSwitch_Android with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Loads existing apartment data into fields
 *
 * @param apartmentId ID of existing Apartment
 */
private void initializeApartmentData(Long apartmentId) {
    try {
        Apartment apartment = DatabaseHandler.getApartment(apartmentId);
        originalName = apartment.getName();
        name.setText(originalName);

        for (Gateway gateway : apartment.getAssociatedGateways()) {
            for (CheckBox checkBox : gatewayCheckboxList) {
                Gateway checkBoxGateway = (Gateway) checkBox.getTag(R.string.gateways);
                if (gateway.getId().equals(checkBoxGateway.getId())) {
                    checkBox.setChecked(true);
                }
            }
        }

    } catch (Exception e) {
        StatusMessageHandler.showErrorMessage(getActivity(), e);
    }
}
 
Example 3
Source File: MultiSelectElement.java    From sana.mobile with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public String getAnswer() {
    Log.i(TAG, "[" + id + "]getAnswer()");
    String val = "";
    if (!isViewActive())
        val = (answer == null) ? "" : answer;
    else {
        boolean any = false;
        // loop over list and add to answer if checked
        for (CheckBox c : cblist) {
            if (c.isChecked()) {
                val += c.getTag() + TOKEN_DELIMITER;
                any = true;
            }
        }
        //Remove trailing
        if (any)
            val = val.substring(0, val.length() - 1);
    }
    Log.d(TAG, "...returning " + val);
    return val;
}
 
Example 4
Source File: ConfigureApartmentDialogPage1NameFragment.java    From PowerSwitch_Android with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Get selected Gateways
 *
 * @return List of Gateways
 */
private ArrayList<Gateway> getCheckedGateways() {
    ArrayList<Gateway> checkedGateways = new ArrayList<>();

    for (CheckBox checkBox : gatewayCheckboxList) {
        if (checkBox.isChecked()) {
            Gateway gateway = (Gateway) checkBox.getTag(R.string.gateways);
            checkedGateways.add(gateway);
        }
    }

    return checkedGateways;
}
 
Example 5
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();
//		}
		
	}