Example usage for android.widget RadioButton setChecked

List of usage examples for android.widget RadioButton setChecked

Introduction

In this page you can find the example usage for android.widget RadioButton setChecked.

Prototype

@Override
public void setChecked(boolean checked) 

Source Link

Document

Changes the checked state of this button.

Usage

From source file:eu.geopaparazzi.library.core.dialogs.ColorStrokeDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle bundle) {

    // create the dialog
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    View colorStrokeDialogView = getActivity().getLayoutInflater()
            .inflate(R.layout.fragment_dialog_color_stroke, null);
    builder.setView(colorStrokeDialogView); // add GUI to dialog

    /*//from  w ww  .j av  a  2  s. c  om
     * the shape size image
     */
    if (!mCurrentColorStrokeObject.hasShape) {
        View shapeSizeView = colorStrokeDialogView.findViewById(R.id.shapeSizeDialogGridLayout);
        shapeSizeView.setVisibility(View.GONE);
    } else {
        //            mShapeSizeImageView = (ImageView) colorStrokeDialogView.findViewById(R.id.shapeSizeImageView);
        mShapeSizeTextView = (TextView) colorStrokeDialogView.findViewById(R.id.shapeSizeTextView);
        mShapeSizeSeekBar = (SeekBar) colorStrokeDialogView.findViewById(R.id.shapeSizeSeekBar);

        mShapeSizeSeekBar.setOnSeekBarChangeListener(shapeSizeChanged);
        mShapeSizeSeekBar.setProgress(mCurrentColorStrokeObject.shapeSize);
        mShapeSizeTextView.setText(String.valueOf(mCurrentColorStrokeObject.shapeSize));

        mShapeSpinner = (Spinner) colorStrokeDialogView.findViewById(R.id.shape_spinner);
        int count = mShapeSpinner.getCount();
        for (int i = 0; i < count; i++) {
            if (mShapeSpinner.getItemAtPosition(i).equals(mCurrentColorStrokeObject.shapeWKT)) {
                mShapeSpinner.setSelection(i);
                break;
            }
        }
        mShapeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
                Object selectedItem = mShapeSpinner.getSelectedItem();
                String shapeStr = selectedItem.toString();
                mCurrentColorStrokeObject.shapeWKT = shapeStr;
            }

            public void onNothingSelected(AdapterView<?> arg0) {
                // ignore
            }
        });

    }

    /*
     * the stroke width image
     */
    if (!mCurrentColorStrokeObject.hasStrokeWidth) {
        View lineWidthView = colorStrokeDialogView.findViewById(R.id.lineWidthDialogGridLayout);
        lineWidthView.setVisibility(View.GONE);
    } else {
        mWidthImageView = (ImageView) colorStrokeDialogView.findViewById(R.id.widthImageView);
        mWidthTextView = (TextView) colorStrokeDialogView.findViewById(R.id.widthTextView);
        mWidthSeekBar = (SeekBar) colorStrokeDialogView.findViewById(R.id.widthSeekBar);

        mWidthSeekBar.setOnSeekBarChangeListener(lineWidthChanged);
        mWidthSeekBar.setProgress(mCurrentColorStrokeObject.strokeWidth);
        mWidthTextView.setText(String.valueOf(mCurrentColorStrokeObject.strokeWidth));
    }

    RadioButton fillRadioButton = (RadioButton) colorStrokeDialogView.findViewById(R.id.doFillRadioButton);
    fillRadioButton.setChecked(true);
    RadioGroup radioGroup = (RadioGroup) colorStrokeDialogView.findViewById(R.id.radioDo);
    radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            onRadioButtonClicked(checkedId);
        }
    });

    /*
     * The fill/stroke color picker part
     */
    TextView title2 = (TextView) colorStrokeDialogView.findViewById(R.id.title2);
    if (!mCurrentColorStrokeObject.hasFill && !mCurrentColorStrokeObject.hasStroke) {
        View colorView = colorStrokeDialogView.findViewById(R.id.colorDialogGridLayout);
        colorView.setVisibility(View.GONE);
    } else {
        if (!mCurrentColorStrokeObject.hasFill || !mCurrentColorStrokeObject.hasStroke) {
            View radioView = colorStrokeDialogView.findViewById(R.id.radioDoLayout);
            radioView.setVisibility(View.GONE);
        }
        handlingFillColor = mCurrentColorStrokeObject.hasFill;
        String title = "";
        if (mCurrentColorStrokeObject.hasFill && mCurrentColorStrokeObject.hasStroke) {
            title = getActivity().getString(R.string.fill_and_stroke_color_title);
        } else if (mCurrentColorStrokeObject.hasFill) {
            title = getActivity().getString(R.string.fill_color_title);
        } else {
            title = getActivity().getString(R.string.stroke_color_title);
        }
        title2.setText(title);

        // get the color SeekBars and set their onChange listeners
        mAlphaSeekBar = (SeekBar) colorStrokeDialogView.findViewById(R.id.alphaSeekBar);
        mRedSeekBar = (SeekBar) colorStrokeDialogView.findViewById(R.id.redSeekBar);
        mGreenSeekBar = (SeekBar) colorStrokeDialogView.findViewById(R.id.greenSeekBar);
        mBlueSeekBar = (SeekBar) colorStrokeDialogView.findViewById(R.id.blueSeekBar);
        mColorView = colorStrokeDialogView.findViewById(R.id.colorView);

        // register SeekBar event listeners
        mAlphaSeekBar.setOnSeekBarChangeListener(colorChangedListener);
        mRedSeekBar.setOnSeekBarChangeListener(colorChangedListener);
        mGreenSeekBar.setOnSeekBarChangeListener(colorChangedListener);
        mBlueSeekBar.setOnSeekBarChangeListener(colorChangedListener);

        int color = 0;
        int alpha = 0;
        if (handlingFillColor) {
            color = mCurrentColorStrokeObject.fillColor;
            alpha = mCurrentColorStrokeObject.fillAlpha;
        } else {
            color = mCurrentColorStrokeObject.strokeColor;
            alpha = mCurrentColorStrokeObject.strokeAlpha;
        }
        // use current drawing color to set SeekBar values
        mAlphaSeekBar.setProgress(alpha);
        mRedSeekBar.setProgress(Color.red(color));
        mGreenSeekBar.setProgress(Color.green(color));
        mBlueSeekBar.setProgress(Color.blue(color));

        final ColorUtilities[] availableColors = ColorUtilities.values();

        GridView gridview = (GridView) colorStrokeDialogView.findViewById(R.id.availableColors);
        ArrayAdapter<ColorUtilities> colorsAdapter = new ArrayAdapter<ColorUtilities>(getActivity(),
                android.R.layout.simple_list_item_1, availableColors) {
            class ViewHolder {
                Button button;
            }

            @Override
            public View getView(final int position, View cView, ViewGroup parent) {
                ViewHolder holder;
                View rowView = cView;
                if (rowView == null) {
                    LayoutInflater inflater = getActivity().getLayoutInflater();
                    rowView = inflater.inflate(R.layout.fragment_dialog_color_stroke_row, parent, false);
                    holder = new ViewHolder();
                    holder.button = (Button) rowView.findViewById(R.id.button);
                    rowView.setTag(holder);
                } else {
                    holder = (ViewHolder) rowView.getTag();
                }
                String hex = availableColors[position].getHex();
                int color = ColorUtilities.toColor(hex);
                holder.button.setBackgroundColor(color);
                final Button b = holder.button;
                holder.button.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        int color = Color.TRANSPARENT;
                        Drawable background = b.getBackground();
                        if (background instanceof ColorDrawable)
                            color = ((ColorDrawable) background).getColor();

                        int red = Color.red(color);
                        int green = Color.green(color);
                        int blue = Color.blue(color);
                        int argb = Color.argb(red, green, blue, mAlphaSeekBar.getProgress());
                        mColorView.setBackgroundColor(argb);
                        mRedSeekBar.setProgress(red);
                        mGreenSeekBar.setProgress(green);
                        mBlueSeekBar.setProgress(blue);
                        if (handlingFillColor) {
                            mCurrentColorStrokeObject.fillColor = Color.rgb(mRedSeekBar.getProgress(),
                                    mGreenSeekBar.getProgress(), mBlueSeekBar.getProgress());
                            mCurrentColorStrokeObject.fillAlpha = mAlphaSeekBar.getProgress();
                        } else {
                            mCurrentColorStrokeObject.strokeColor = Color.rgb(mRedSeekBar.getProgress(),
                                    mGreenSeekBar.getProgress(), mBlueSeekBar.getProgress());
                            mCurrentColorStrokeObject.strokeAlpha = mAlphaSeekBar.getProgress();
                        }
                    }
                });

                return rowView;
            }

        };
        gridview.setAdapter(colorsAdapter);

    }

    // add Set Line Width Button
    builder.setPositiveButton(R.string.set_properties, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            if (colorStrokePropertiesChangeListener != null) {
                colorStrokePropertiesChangeListener.onPropertiesChanged(mCurrentColorStrokeObject);
            }
        }
    });
    builder.setNegativeButton(getString(android.R.string.cancel), new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
        }
    });

    return builder.create(); // return dialog
}

From source file:com.trimph.toprand.trimphrxandroid.trimph.ui.main.news.view.PagerSlidingTabStrip.java

private void updateTabCheckedState(int position) {
    if (tabsContainer.getChildCount() <= position) {
        return;//from  www  . ja  v  a  2 s.  co  m
    }
    View view = tabsContainer.getChildAt(position);
    if (null == tabsContainer) {
        return;
    }
    if (!(view instanceof RadioButton)) {
        return;
    }
    RadioButton radioButton = (RadioButton) view;
    if (null == radioButton) {
        return;
    }
    radioButton.setChecked(true);
}

From source file:org.proninyaroslav.libretorrent.fragments.DetailTorrentFilesFragment.java

@Override
public void onShow(AlertDialog dialog) {
    if (dialog != null && getFragmentManager().findFragmentByTag(TAG_PRIORITY_DIALOG) != null) {
        if (curDir == null) {
            return;
        }//  ww  w . j a  v  a  2 s .  com

        List<Priority> priorities = new ArrayList<>();

        for (String name : selectedFiles) {
            TorrentContentFileTree file = curDir.getChild(name);
            if (file != null) {
                priorities.add(file.getPriority());
            }
        }

        /*
         * We compare the array with randomly selected priority.
         * If all elements equals with this priority, set isMixedPriority as true and based on
         * the random priority choosing radio button, which will be checked by default.
         * Else, set isMixedPriority as false and clear check in RadioGroup
         */

        Priority randomPriority = priorities.get(new Random().nextInt(priorities.size()));
        boolean isMixedPriority = false;

        if (randomPriority == Priority.UNKNOWN) {
            isMixedPriority = true;
        } else {
            for (Priority priority : priorities) {
                if (randomPriority != priority) {
                    isMixedPriority = true;
                    break;
                }
            }
        }

        if (!isMixedPriority) {
            int resId;
            switch (randomPriority) {
            case IGNORE:
                resId = R.id.dialog_priority_low;
                break;
            case SEVEN:
                resId = R.id.dialog_priority_high;
                break;
            default:
                resId = R.id.dialog_priority_normal;
            }

            RadioButton button = (RadioButton) dialog.findViewById(resId);
            if (button != null) {
                button.setChecked(true);
            }
        } else {
            RadioGroup group = (RadioGroup) dialog.findViewById(R.id.dialog_priorities_group);
            if (group != null) {
                group.clearCheck();
            }
        }
    }
}

From source file:th.in.ffc.person.visit.VisitAncActivity.java

public void doInitailizeViewByCursor(Cursor c) {
    String hos_serv = c.getString(c.getColumnIndex(VisitAnc.HOSPITAL_SERVICE));
    if (!TextUtils.isEmpty(hos_serv))
        mServiceAt.setSelectionById(hos_serv);
    String dtAnc = c.getString(c.getColumnIndex(VisitAnc.DTANC));
    if (!TextUtils.isEmpty(dtAnc))
        mDTanc.setSelection(dtAnc);//from   w  w w  .  j a  v a  2  s.  co m

    // Anc general vital check
    mWeight.setText(c.getString(c.getColumnIndex(VisitAnc.WEIGHT)));
    mHeight.setText(c.getString(c.getColumnIndex(VisitAnc.HEIGHT)));
    mBmi.setText(c.getString(c.getColumnIndex(VisitAnc.BMI)));
    mTooth.setChecked(c.getInt(c.getColumnIndex(VisitAnc.TOOTH_CHECK)) == 1 ? true : false);
    mCaries.setText(c.getString(c.getColumnIndex(VisitAnc.CARIES)));
    mTarTar.setSelection(c.getString(c.getColumnIndex(VisitAnc.TARTAR)));
    mGum.setSelection(c.getString(c.getColumnIndex(VisitAnc.GUM_FAIL)));

    // abnormal checkboxs
    mNipple.setChecked(c.getInt(c.getColumnIndex(VisitAnc.BREAST_CHECK)) == 0 ? true : false);
    mUrinary.setChecked(c.getInt(c.getColumnIndex(VisitAnc.URINARY)) == 0 ? true : false);
    mHeadAche.setChecked(c.getInt(c.getColumnIndex(VisitAnc.HEADAHCE)) == 1 ? true : false);
    mSickening.setChecked(c.getInt(c.getColumnIndex(VisitAnc.SICKENING)) == 1 ? true : false);
    mTyroid.setChecked(c.getInt(c.getColumnIndex(VisitAnc.TYROID)) == 1 ? true : false);
    mLeucorrhea.setChecked(c.getInt(c.getColumnIndex(VisitAnc.UTMUGO)) == 1 ? true : false);
    mEdema.setChecked(c.getInt(c.getColumnIndex(VisitAnc.EDEMA)) == 1 ? true : false);
    mUterus.setChecked(c.getInt(c.getColumnIndex(VisitAnc.UTBLOOD)) == 1 ? true : false);
    mCramp.setChecked(c.getInt(c.getColumnIndex(VisitAnc.CRAMP)) == 1 ? true : false);
    mHeartAtk.setChecked(c.getInt(c.getColumnIndex(VisitAnc.HEART_ATTACK)) == 1 ? true : false);
    // abnormal spinner
    mFundus.setSelection(c.getString(c.getColumnIndex(VisitAnc.FUNDUS)));
    mSugar.setSelection(c.getString(c.getColumnIndex(VisitAnc.SUGAR)));
    mAlbumin.setSelection(c.getString(c.getColumnIndex(VisitAnc.ALBUMIN)));

    // baby health section
    mBabyDance.setChecked(c.getInt(c.getColumnIndex(VisitAnc.DANCE_BABY)) == 1 ? true : false);
    mBabyHear.setSelection(c.getString(c.getColumnIndex(VisitAnc.HEART_BABY)));
    mBabyCount.setText(c.getString(c.getColumnIndex(VisitAnc.HEART_BABY_COUNT)));
    mBabyPostion.setSelection(c.getString(c.getColumnIndex(VisitAnc.POSITION_BABY)));
    mBabyPilot.setSelection(c.getString(c.getColumnIndex(VisitAnc.PILOT)));
    mBabyTalas.setSelection(c.getString(c.getColumnIndex(VisitAnc.THALAS_BABY_CHECK)));

    boolean usaully = c.getInt(c.getColumnIndex(VisitAnc.ANCRES)) == 1 ? true : false;
    if (usaully) {
        RadioButton rUsually = (RadioButton) findViewById(R.id.answer1);
        rUsually.setChecked(true);
    } else {
        RadioButton rUnusually = (RadioButton) findViewById(R.id.answer2);
        rUnusually.setChecked(true);
    }

    if (mAction.equals(Action.EDIT)) {
        String appoint = c.getString(c.getColumnIndex(VisitAnc.DATE_APPOINT));
        if (!TextUtils.isEmpty(appoint)) {
            mAppointChk.setChecked(true);
            Date da = Date.newInstance(appoint);
            mAppointDate.updateDate(da.year, da.month - 1, da.day);
        }

        String dtanc = c.getString(c.getColumnIndex(VisitAnc.DTANC));
        if (!TextUtils.isEmpty(dtanc) && !dtanc.equals("tt_in_scope")) {
            mDTanc.setSelection(0);
        }

    }

}

From source file:org.ounl.lifelonglearninghub.fcube.navigate.SwipeFragmentActivity.java

/**
 * On click one audio radiobutton, deselect the rest of the radiobuttons
 * //ww w  . jav a2 s. c o  m
 * @param v
 */
public void onSelectAudioRadioButton(View v) {

    LinearLayout llRadioButton = (LinearLayout) v.getParent();
    LinearLayout llRoot = (LinearLayout) llRadioButton.getParent();

    RadioButton rbB = (RadioButton) llRoot.findViewById(R.id.rbBeep);
    RadioButton rbM = (RadioButton) llRoot.findViewById(R.id.rbMelody1);

    String sTag = v.getTag().toString();
    if (getString(R.string.rb_beep).compareTo(sTag) == 0) {

        rbM.setChecked(false);

    } else if (getString(R.string.rb_melody).compareTo(sTag) == 0) {

        rbB.setChecked(false);

    }

}

From source file:org.ounl.lifelonglearninghub.fcube.navigate.SwipeFragmentActivity.java

/**
 * On click one color radiobutton, deselect the rest of the radiobuttons
 * //from  www  .j  a  va2 s  . c  om
 * @param v
 */
public void onSelectColorRadioButton(View v) {

    LinearLayout llRadioButton = (LinearLayout) v.getParent();
    LinearLayout llRoot = (LinearLayout) llRadioButton.getParent();

    RadioButton rbF = (RadioButton) llRoot.findViewById(R.id.rbFullColor);
    RadioButton rbP = (RadioButton) llRoot.findViewById(R.id.rbPartColor);

    String sTag = v.getTag().toString();
    if (getString(R.string.rb_fully).compareTo(sTag) == 0) {

        rbP.setChecked(false);

    } else if (getString(R.string.rb_partly).compareTo(sTag) == 0) {

        rbF.setChecked(false);

    }

}

From source file:org.ounl.lifelonglearninghub.fcube.navigate.VisualSectionFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.activity_display_visual, container, false);

    ///*from  ww  w  .  j  a  va2  s . c o m*/
    // Init seekbars
    //
    final TextView tvColorSample = (TextView) rootView.findViewById(R.id.tvColorSample);

    SeekBar sbRed = (SeekBar) rootView.findViewById(R.id.seekBarRed);
    sbRed.setMax(255);
    final TextView tvRValue = (TextView) rootView.findViewById(R.id.textViewRedValue);

    SeekBar sbG = (SeekBar) rootView.findViewById(R.id.seekBarGreen);
    sbG.setMax(255);
    final TextView tvGValue = (TextView) rootView.findViewById(R.id.textViewGreenValue);

    SeekBar sbB = (SeekBar) rootView.findViewById(R.id.seekBarBlue);
    sbB.setMax(255);
    final TextView tvBValue = (TextView) rootView.findViewById(R.id.textViewBlueValue);

    sbRed.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {

            tvRValue.setText(String.valueOf(progress));

            String sR = (String) tvRValue.getText();
            Integer IsR = new Integer(sR);

            String sG = (String) tvGValue.getText();
            Integer IsG = new Integer(sG);

            String sB = (String) tvBValue.getText();
            Integer IsB = new Integer(sB);

            String hex = String.format("#%02x%02x%02x", IsR, IsG, IsB);

            tvColorSample.setBackgroundColor(Color.parseColor(hex));
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
        }
    });

    sbG.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {

            tvGValue.setText(String.valueOf(progress));

            String sR = (String) tvRValue.getText();
            Integer IsR = new Integer(sR);

            String sG = (String) tvGValue.getText();
            Integer IsG = new Integer(sG);

            String sB = (String) tvBValue.getText();
            Integer IsB = new Integer(sB);

            String hex = String.format("#%02x%02x%02x", IsR, IsG, IsB);

            tvColorSample.setBackgroundColor(Color.parseColor(hex));
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
        }
    });

    sbB.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {

            tvBValue.setText(String.valueOf(progress));

            String sR = (String) tvRValue.getText();
            Integer IsR = new Integer(sR);

            String sG = (String) tvGValue.getText();
            Integer IsG = new Integer(sG);

            String sB = (String) tvBValue.getText();
            Integer IsB = new Integer(sB);

            String hex = String.format("#%02x%02x%02x", IsR, IsG, IsB);

            tvColorSample.setBackgroundColor(Color.parseColor(hex));
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
        }
    });

    //
    // Init number pickers
    // 
    final RadioButton rbF = (RadioButton) rootView.findViewById(R.id.rbFullColor);
    final RadioButton rbP = (RadioButton) rootView.findViewById(R.id.rbPartColor);

    npLedStart = (NumberPicker) rootView.findViewById(R.id.npLedStart);
    npLedStart.setMaxValue(15);
    npLedStart.setMinValue(0);
    npLedStart.setValue(0);
    //npLedStart.setWrapSelectorWheel(false);
    npLedStart.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
        @Override
        public void onValueChange(NumberPicker numberPicker, int i, int i2) {
            rbP.setChecked(true);
            rbF.setChecked(false);

        }
    });

    npLedEnd = (NumberPicker) rootView.findViewById(R.id.npLedStop);
    npLedEnd.setMaxValue(15);
    npLedEnd.setMinValue(0);
    npLedEnd.setValue(15);
    //npLedEnd.setWrapSelectorWheel(false);
    npLedEnd.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
        @Override
        public void onValueChange(NumberPicker numberPicker, int i, int i2) {
            rbP.setChecked(true);
            rbF.setChecked(false);
        }
    });

    return rootView;
}

From source file:itkach.aard2.SettingsListAdapter.java

private View getRemoteContentSettingsView(View convertView, ViewGroup parent) {
    View view;/*  ww  w. j av a  2  s.  c o  m*/
    if (convertView != null) {
        view = convertView;
    } else {
        LayoutInflater inflater = (LayoutInflater) parent.getContext()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view = inflater.inflate(R.layout.settings_remote_content_item, parent, false);

        final SharedPreferences prefs = view.getContext().getSharedPreferences(ArticleWebView.PREF,
                Activity.MODE_PRIVATE);

        String currentValue = prefs.getString(ArticleWebView.PREF_REMOTE_CONTENT,
                ArticleWebView.PREF_REMOTE_CONTENT_WIFI);
        Log.d("Settings", "Remote content, current value: " + currentValue);

        View.OnClickListener clickListener = new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                SharedPreferences.Editor editor = prefs.edit();
                String value = null;
                switch (view.getId()) {
                case R.id.setting_remote_content_always:
                    value = ArticleWebView.PREF_REMOTE_CONTENT_ALWAYS;
                    break;
                case R.id.setting_remote_content_wifi:
                    value = ArticleWebView.PREF_REMOTE_CONTENT_WIFI;
                    break;
                case R.id.setting_remote_content_never:
                    value = ArticleWebView.PREF_REMOTE_CONTENT_NEVER;
                    break;
                }
                Log.d("Settings", "Remote content: " + value);
                if (value != null) {
                    editor.putString(ArticleWebView.PREF_REMOTE_CONTENT, value);
                    editor.commit();
                }
            }
        };
        RadioButton btnAlways = (RadioButton) view.findViewById(R.id.setting_remote_content_always);
        RadioButton btnWiFi = (RadioButton) view.findViewById(R.id.setting_remote_content_wifi);
        RadioButton btnNever = (RadioButton) view.findViewById(R.id.setting_remote_content_never);
        btnAlways.setOnClickListener(clickListener);
        btnWiFi.setOnClickListener(clickListener);
        btnNever.setOnClickListener(clickListener);
        btnAlways.setChecked(currentValue.equals(ArticleWebView.PREF_REMOTE_CONTENT_ALWAYS));
        btnWiFi.setChecked(currentValue.equals(ArticleWebView.PREF_REMOTE_CONTENT_WIFI));
        btnNever.setChecked(currentValue.equals(ArticleWebView.PREF_REMOTE_CONTENT_NEVER));
    }
    ;
    return view;
}

From source file:th.in.ffc.person.visit.VisitAncActivity.java

public void doInitailizeView(Bundle savedInstanceState) {
    mPregno = (EditText) findViewById(R.id.code);
    mPregAdd = (ImageButton) findViewById(R.id.edit);
    mPregAdd.setOnClickListener(new View.OnClickListener() {

        @Override//w w  w  .  j av a 2 s  .co m
        public void onClick(View v) {
            if (!TextUtils.isEmpty(mPreg)) {
                Intent intent = new Intent(VisitAncActivity.this, VisitAncPregnancyActivity.class);
                intent.setAction(Action.EDIT);
                intent.putExtra(PregnancyColumns._PREGNO, mPreg);
                startVisitActivityForResult(intent, REQUEST_PREG_MANUAL);
            }
        }
    });
    mPregAge = (EditText) findViewById(R.id.age);
    mAncNo = (ArrayFormatSpinner) findViewById(R.id.anc);
    mAncNo.setArray(R.array.ancno);
    mAncNo.setEnabled(false);
    mServiceAt = (SearchableButton) findViewById(R.id.hospital);
    mServiceAt.setDialog(getSupportFragmentManager(), HospitalListDialog.class, "hos");
    mDTanc = (ArrayFormatSpinner) findViewById(R.id.epi);
    mDTanc.setArray(R.array.dtanc);
    mDTanc.setSelection(1);
    mDTanc.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {

            mEpiBtn.setEnabled(arg2 == 0 ? true : false);
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
        }
    });

    mEpiBtn = (ImageButton) findViewById(R.id.answer3);
    mEpiBtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (mDTanc.getSelectedItemPosition() == 0) {
                Intent epi = new Intent(VisitAncActivity.this, VisitEpiActivity.class);
                epi.setAction(Action.EPI_PREGNANCY);
                epi.setData(Uri.withAppendedPath(Visit.CONTENT_URI, getVisitNo()));
                startVisitActivityForResult(epi, REQUEST_EPI);
            }
        }
    });

    mWeight = (EditText) findViewById(R.id.weight);
    mWeight.addTextChangedListener(bmiWatcher);
    mHeight = (EditText) findViewById(R.id.height);
    mHeight.addTextChangedListener(bmiWatcher);
    mBmi = (TextView) findViewById(R.id.bmi);
    mBmi.setVisibility(View.GONE);

    mTooth = (CheckBox) findViewById(R.id.tooth);
    mTooth.setChecked(true);
    mTooth.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

            mCaries.setEnabled(isChecked);
            mTarTar.setEnabled(isChecked);
            mGum.setEnabled(isChecked);
        }
    });
    mCaries = (EditText) findViewById(R.id.caries);
    mTarTar = (ArrayFormatSpinner) findViewById(R.id.tartar);
    mTarTar.setArray(R.array.have_nothave);
    mGum = (ArrayFormatSpinner) findViewById(R.id.gum);
    mGum.setArray(R.array.have_nothave);

    mNipple = (CheckBox) findViewById(R.id.nipple);
    mHeadAche = (CheckBox) findViewById(R.id.head);
    mSickening = (CheckBox) findViewById(R.id.sickening);
    mTyroid = (CheckBox) findViewById(R.id.tyroid);
    mLeucorrhea = (CheckBox) findViewById(R.id.leucorrhea);
    mEdema = (CheckBox) findViewById(R.id.edema);
    mUterus = (CheckBox) findViewById(R.id.uterus);
    mCramp = (CheckBox) findViewById(R.id.cramp);
    mUrinary = (CheckBox) findViewById(R.id.urinary);
    mHeartAtk = (CheckBox) findViewById(R.id.heart);

    mFundus = (ArrayFormatSpinner) findViewById(R.id.fundus);
    mFundus.setArray(R.array.fundus);
    mSugar = (ArrayFormatSpinner) findViewById(R.id.sugar);
    mSugar.setArray(R.array.urinary_lvl);
    mAlbumin = (ArrayFormatSpinner) findViewById(R.id.albumin);
    mAlbumin.setArray(R.array.urinary_lvl);

    mBabyDance = (CheckBox) findViewById(R.id.dance);
    mBabyHear = (ArrayFormatSpinner) findViewById(R.id.hear);
    mBabyHear.setArray(R.array.baby_hear);
    mBabyPostion = (ArrayFormatSpinner) findViewById(R.id.position);
    mBabyPostion.setArray(R.array.baby_position);
    mBabyPilot = (ArrayFormatSpinner) findViewById(R.id.pilot);
    mBabyPilot.setArray(R.array.baby_pilot);
    mBabyCount = (EditText) findViewById(R.id.count);
    mBabyTalas = (ArrayFormatSpinner) findViewById(R.id.talas);
    mBabyTalas.setArray(R.array.baby_talas);

    mSummarize = (RadioGroup) findViewById(R.id.summarize);
    mAppointChk = (CheckBox) findViewById(R.id.check);
    mAppointChk.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            mAppointDate.setVisibility(isChecked ? View.VISIBLE : View.GONE);
        }
    });
    mAppointDate = (ThaiDatePicker) findViewById(R.id.date);
    Date date = Date.newInstance(DateTime.getCurrentDateTime());
    mAppointDate.updateDate(date.year, date.month - 1, date.day);

    if (savedInstanceState == null) {
        mServiceAt.setSelectionById(getPcuCode());
        mTooth.setChecked(true);
        mBabyDance.setChecked(true);
        mBabyHear.setSelection("2");
        RadioButton usually = (RadioButton) findViewById(R.id.answer1);
        usually.setChecked(true);
    } else {
        mAppointDate.setVisibility(mAppointChk.isChecked() ? View.VISIBLE : View.GONE);
    }
}

From source file:com.lokiy.widget.BannerView.java

private RadioButton generateRadioButton(int i, int w) {
    RadioButton rb = new RadioButton(getContext());
    rb.setBackgroundResource(mIndicatorId);
    rb.setButtonDrawable(new BitmapDrawable(getResources(), (Bitmap) null));
    rb.setId(i);//from  w ww . j  a v  a 2 s.  c o m
    rb.setPadding(0, 0, 0, 0);
    RadioGroup.LayoutParams params = new RadioGroup.LayoutParams(w, w);
    params.leftMargin = w / 2;
    params.rightMargin = w / 2;
    rb.setLayoutParams(params);
    if (i == 0) {
        rb.setChecked(true);
    }
    return rb;
}