Example usage for android.widget RadioGroup getChildCount

List of usage examples for android.widget RadioGroup getChildCount

Introduction

In this page you can find the example usage for android.widget RadioGroup getChildCount.

Prototype

public int getChildCount() 

Source Link

Document

Returns the number of children in the group.

Usage

From source file:com.lauren.simplenews.view.MainBottomTab.java

@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
    if (this.viewPager != null) {
        for (int i = 0; i < group.getChildCount(); i++) {
            if (group.getChildAt(i).getId() == checkedId) {
                this.viewPager.setCurrentItem(i, false);
            }//from  w  ww.  ja v a 2 s.  c  o m
        }
    }
}

From source file:cn.ieclipse.af.demo.common.ui.MainBottomTab.java

@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
    if (this.viewPager != null) {
        for (int i = 0; i < group.getChildCount(); i++) {
            if (group.getChildAt(i).getId() == checkedId) {
                this.viewPager.setCurrentItem(i, true);
            }/*  ww w .  jav  a2  s .  c  o m*/
        }
    }
}

From source file:com.mifos.mifosxdroid.online.SurveyQuestionFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.fragment_survey_question, container, false);
    ButterKnife.inject(this, view);
    thiscontext = container.getContext();
    mQuestionDatas = (new Gson()).fromJson(getArguments().getString(QUESTION_DATA), QuestionDatas.class);
    mScorecardValues = new ScorecardValues();

    tv_question.setText(mQuestionDatas.getText());

    ViewGroup hourButtonLayout = (ViewGroup) view.findViewById(R.id.radio1);
    for (int i = 0; i < mQuestionDatas.getResponseDatas().size(); i++) {
        button1 = new RadioButton(thiscontext);
        button1.setId(i);//from w  w w.  j  av  a  2  s .c o m
        button1.setText(mQuestionDatas.getResponseDatas().get(i).getText());
        hourButtonLayout.addView(button1);
        radioGroup1.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            public void onCheckedChanged(RadioGroup mRadioGroup2, int checkedId2) {
                for (int j = 0; j < mRadioGroup2.getChildCount(); j++) {
                    btn = (RadioButton) mRadioGroup2.getChildAt(j);
                    int t = mRadioGroup2.getId();
                    Log.d(LOG_TAG, "" + t);

                    if (btn.getId() == checkedId2) {
                        answer = btn.getText().toString();
                        mScorecardValues.setQuestionId(mQuestionDatas.getQuestionId());
                        mScorecardValues
                                .setResponseId(mQuestionDatas.getResponseDatas().get(j).getResponseId());
                        mScorecardValues.setValue(mQuestionDatas.getResponseDatas().get(j).getValue());
                        mCallback.answer(mScorecardValues);
                        Log.d(LOG_TAG,
                                "Q R V" + mQuestionDatas.getQuestionId() + " "
                                        + mQuestionDatas.getResponseDatas().get(j).getResponseId() + " "
                                        + mQuestionDatas.getResponseDatas().get(j).getValue());
                        return;
                    }
                }
            }
        });
    }

    return view;
}

From source file:com.sweetiepiggy.littlepro.QuestionFragment.java

public void onSubmit(String correctAnswer) {
    mSubmitted = true;/*from   www.  j  a v a2 s.  c  om*/
    View view = getView();
    if (view != null) {
        view.findViewById(R.id.answer).setEnabled(false);

        RadioGroup radioGroup = (RadioGroup) view.findViewById(R.id.answerRadioGroup);
        for (int i = 0; i < radioGroup.getChildCount(); ++i) {
            radioGroup.getChildAt(i).setEnabled(false);
        }
    }
}

From source file:fi.tuukka.weather.view.FragmentStations.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    view = inflater.inflate(R.layout.asemat, container, false);
    rg = (RadioGroup) view.findViewById(R.id.radioGroup1);
    rg.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override/*from   w  ww  .j a v a  2s .  c  o m*/
        public void onCheckedChanged(RadioGroup rg, int id) {
            if (listenCheck) {
                for (int i = 0; i < rg.getChildCount(); i++) {
                    RadioButton btn = (RadioButton) rg.getChildAt(i);
                    if (btn.getId() == id) {
                        String text = (String) btn.getText();
                        Station station = new Station(text, null);
                        changeStation(station);
                        refreshStations();
                        return;
                    }
                }
            }
        }
    });
    EditText searchBox = (EditText) view.findViewById(R.id.stationSearchBox);
    searchBox.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void afterTextChanged(Editable s) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            String string = s.toString();
            if (query == null || !query.equals(string)) {
                query = s.toString();
                stationStrings = null; // mark as not finished
                ((ActivityMain) getActivity()).queryStations();
            }
        }
    });
    Activity activity = getActivity();
    header = (TextView) view.findViewById(R.id.stationsHeader);
    int fontsize = Utils.getScaledFont(activity);
    int pad = Utils.dpToPx(5, activity);
    header.setTextAppearance(activity, R.style.TextStyle);
    header.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontsize);
    header.setPadding(0, pad, 0, pad);
    header.setText("Syt kunta/kunnanosa:");
    super.onCreateView(inflater, container, savedInstanceState);
    return view;
}

From source file:com.odoo.base.login_signup.SyncWizard.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // handle item selection

    switch (item.getItemId()) {
    case R.id.menu_start_application:
        for (CheckBox chkBox : checkbox) {
            if (chkBox != null) {
                String authority = authorities.get(chkBox.getId() + "").toString();
                scope.main().setAutoSync(authority, chkBox.isChecked());
                scope.main().cancelSync(authority);
            }// w  ww .  j  a  v a2 s  . co  m
        }
        for (RadioGroup rdoGrp : rdoGroups) {
            if (rdoGrp != null) {
                for (int i = 0; i < rdoGrp.getChildCount(); i++) {
                    RadioButton rdoBtn = (RadioButton) rdoGrp.getChildAt(i);
                    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(scope.context());
                    Editor editor = settings.edit();
                    // TODO: store preference setting for your options.
                    editor.commit();
                    String authority = authorities.get(rdoBtn.getId() + "");
                    scope.main().setAutoSync(authority, rdoBtn.isChecked());
                    scope.main().cancelSync(authority);
                }
            }
        }
        getActivity().finish();
        getActivity().startActivity(getActivity().getIntent());
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.openerp.base.login.SyncWizard.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // handle item selection

    int itemId = item.getItemId();
    if (itemId == R.id.menu_start_application) {
        for (CheckBox chkBox : checkbox) {
            if (chkBox != null) {
                String authority = authorities.get(chkBox.getId() + "").toString();
                scope.main().setAutoSync(authority, chkBox.isChecked());
                scope.main().cancelSync(authority);
            }//from   w  ww .  ja va  2s  .c  om
        }
        for (RadioGroup rdoGrp : rdoGroups) {
            if (rdoGrp != null) {
                for (int i = 0; i < rdoGrp.getChildCount(); i++) {
                    RadioButton rdoBtn = (RadioButton) rdoGrp.getChildAt(i);
                    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(scope.context());
                    Editor editor = settings.edit();
                    //TODO: store preference setting for your options.
                    editor.commit();
                    String authority = authorities.get(rdoBtn.getId() + "");
                    scope.main().setAutoSync(authority, rdoBtn.isChecked());
                    scope.main().cancelSync(authority);
                }
            }
        }
        getActivity().finish();
        getActivity().startActivity(getActivity().getIntent());
        return true;
    } else {
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.keysolutions.meteorparties.PartyDetailFragment.java

/**
 * Updates current RSVP display/* w  w w .j  a va2  s.c  om*/
 * @param rootView root view holding all the fields
 */
@SuppressLint("NewApi")
public void updateMyRsvpDisplay(View rootView) {
    // add info about my RSVP
    boolean isLoggedIn = MyDDPState.getInstance().isLoggedIn();
    ((View) (rootView.findViewById(R.id.login_for_rsvp)))
            .setVisibility(isLoggedIn ? View.INVISIBLE : View.VISIBLE);
    ((View) (rootView.findViewById(R.id.rsvp_buttons)))
            .setVisibility(isLoggedIn ? View.VISIBLE : View.INVISIBLE);
    ((View) (rootView.findViewById(R.id.label_my_rsvp)))
            .setVisibility(isLoggedIn ? View.VISIBLE : View.INVISIBLE);

    if (isLoggedIn) {
        RadioGroup rsvpButtons = ((RadioGroup) rootView.findViewById(R.id.rsvp_buttons));
        rsvpButtons.setOnCheckedChangeListener(new OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int checkedId) {
                for (int j = 0; j < radioGroup.getChildCount(); j++) {
                    final ToggleButton view = (ToggleButton) radioGroup.getChildAt(j);
                    view.setChecked(view.getId() == checkedId);
                }
            }
        });
        ToggleButton btnYes = ((ToggleButton) rootView.findViewById(R.id.rsvp_yes));
        ToggleButton btnNo = ((ToggleButton) rootView.findViewById(R.id.rsvp_no));
        ToggleButton btnMaybe = ((ToggleButton) rootView.findViewById(R.id.rsvp_maybe));
        OnClickListener toggleListener = new OnClickListener() {
            @Override
            public void onClick(View v) {
                onToggle(v);
            }
        };
        btnYes.setOnClickListener(toggleListener);
        btnNo.setOnClickListener(toggleListener);
        btnMaybe.setOnClickListener(toggleListener);
        String myRsvp = getMyRsvp();
        if (myRsvp != null) {
            if (myRsvp.equals("yes")) {
                rsvpButtons.check(R.id.rsvp_yes);
            } else if (myRsvp.equals("no")) {
                rsvpButtons.check(R.id.rsvp_no);
            } else if (myRsvp.equals("maybe")) {
                rsvpButtons.check(R.id.rsvp_maybe);
            }
        }

        // if we can, add button animation on Yes because it's cool
        if (android.os.Build.VERSION.SDK_INT > 11) {
            btnYes.animate().setDuration(200);
            btnYes.setOnTouchListener(new OnTouchListener() {
                @Override
                public boolean onTouch(View button, MotionEvent event) {
                    if (event.getAction() == MotionEvent.ACTION_DOWN) {
                        ((ToggleButton) button).animate().setInterpolator(sDecelerator).scaleX(.7f).scaleY(.7f);
                    } else {
                        ((ToggleButton) button).animate().setInterpolator(sOverShooter).scaleX(1f).scaleY(1f);
                    }
                    return false;
                }
            });
        }
    }
}

From source file:org.onebusaway.android.report.ui.Open311ProblemFragment.java

/**
 * Creates open311 question and answer attributes to submit a report
 * Reads from dynamically created UI/* w  w w  .ja v  a  2 s . com*/
 *
 * @param serviceDescription contains attribute types
 * @return List of code value pair of attributes
 */
private List<Open311AttributePair> createOpen311Attributes(ServiceDescription serviceDescription) {
    List<Open311AttributePair> attributes = new ArrayList<>();

    for (Open311Attribute open311Attribute : serviceDescription.getAttributes()) {

        if (Boolean.valueOf(open311Attribute.getVariable())) {
            if (Open311DataType.STRING.equals(open311Attribute.getDatatype())
                    || Open311DataType.NUMBER.equals(open311Attribute.getDatatype())
                    || Open311DataType.DATETIME.equals(open311Attribute.getDatatype())) {
                EditText et = (EditText) mDynamicAttributeUIMap.get(open311Attribute.getCode());
                if (et != null) {
                    attributes.add(new Open311AttributePair(open311Attribute.getCode(), et.getText().toString(),
                            open311Attribute.getDatatype()));
                }
            } else if (Open311DataType.SINGLEVALUELIST.equals(open311Attribute.getDatatype())) {
                RadioGroup rg = (RadioGroup) mDynamicAttributeUIMap.get(open311Attribute.getCode());
                if (rg != null) {
                    int count = rg.getChildCount();
                    for (int i = 0; i < count; i++) {
                        RadioButton rb = (RadioButton) rg.getChildAt(i);
                        if (rb.isChecked()) {
                            String attributeKey = mOpen311AttributeKeyNameMap
                                    .get(open311Attribute.getCode() + rb.getText().toString());
                            attributes.add(new Open311AttributePair(open311Attribute.getCode(), attributeKey,
                                    open311Attribute.getDatatype()));
                            break;
                        }
                    }
                }
            } else if (Open311DataType.MULTIVALUELIST.equals(open311Attribute.getDatatype())) {
                LinearLayout ll = (LinearLayout) mDynamicAttributeUIMap.get(open311Attribute.getCode());
                if (ll != null) {
                    int count = ll.getChildCount();
                    for (int i = 0; i < count; i++) {
                        CheckBox cb = (CheckBox) ll.getChildAt(i);
                        if (cb.isChecked()) {
                            String attributeKey = mOpen311AttributeKeyNameMap
                                    .get(open311Attribute.getCode() + cb.getText().toString());
                            attributes.add(new Open311AttributePair(open311Attribute.getCode(), attributeKey,
                                    open311Attribute.getDatatype()));
                        }
                    }
                }
            }
        }
    }
    return attributes;
}

From source file:org.onebusaway.android.report.ui.Open311ProblemFragment.java

/**
 * This method dynamically reads all user inputted the values from the screen and puts into a
 * list//w w w.  j av a2  s. c  om
 *
 * @param serviceDescription displayed service description
 * @return List of attribute values
 */
private List<AttributeValue> createAttributeValues(ServiceDescription serviceDescription) {
    List<AttributeValue> values = new ArrayList<>();

    if (serviceDescription == null) {
        return values;
    }

    for (Open311Attribute open311Attribute : serviceDescription.getAttributes()) {
        if (Boolean.valueOf(open311Attribute.getVariable())) {
            if (Open311DataType.STRING.equals(open311Attribute.getDatatype())
                    || Open311DataType.NUMBER.equals(open311Attribute.getDatatype())
                    || Open311DataType.DATETIME.equals(open311Attribute.getDatatype())) {
                EditText et = (EditText) mDynamicAttributeUIMap.get(open311Attribute.getCode());
                if (et != null) {
                    AttributeValue value = new AttributeValue(open311Attribute.getCode());
                    value.addValue(et.getText().toString());
                    values.add(value);
                }
            } else if (Open311DataType.SINGLEVALUELIST.equals(open311Attribute.getDatatype())) {
                RadioGroup rg = (RadioGroup) mDynamicAttributeUIMap.get(open311Attribute.getCode());
                if (rg != null) {
                    int count = rg.getChildCount();
                    for (int i = 0; i < count; i++) {
                        RadioButton rb = (RadioButton) rg.getChildAt(i);
                        if (rb.isChecked()) {
                            AttributeValue value = new AttributeValue(open311Attribute.getCode());
                            value.addValue(rb.getText().toString());
                            values.add(value);
                            break;
                        }
                    }
                }
            } else if (Open311DataType.MULTIVALUELIST.equals(open311Attribute.getDatatype())) {
                LinearLayout ll = (LinearLayout) mDynamicAttributeUIMap.get(open311Attribute.getCode());
                if (ll != null) {
                    int count = ll.getChildCount();
                    AttributeValue value = new AttributeValue(open311Attribute.getCode());
                    for (int i = 0; i < count; i++) {
                        CheckBox cb = (CheckBox) ll.getChildAt(i);
                        if (cb.isChecked()) {
                            value.addValue(cb.getText().toString());
                        }
                    }
                    if (value.getValues().size() > 0)
                        values.add(value);
                }
            }
        }
    }
    return values;
}