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:transapps.gpxfitness.ui.MainActivity.java

public void editProfileAlertDialog() {
    if (!ProfileAccessor.isProfileSet()) {
        profileAlertDialog();/*from ww w.j  av a  2  s  .c o m*/
        return;
    }
    final Dialog dialog = new Dialog(this);
    dialog.setContentView(R.layout.profile_dialog);
    dialog.setTitle("Edit Profile:");
    dialog.setCancelable(true);

    Button ok_button = (Button) dialog.findViewById(R.id.button);
    ok_button.setText("Ok");
    final EditText username = (EditText) dialog.findViewById(R.id.username);
    username.setText(ProfileAccessor.getUsername());
    final EditText height_ft = (EditText) dialog.findViewById(R.id.height_ft);
    height_ft.setText("" + (int) ProfileAccessor.getHeight() / 12);
    final EditText height_in = (EditText) dialog.findViewById(R.id.height_in);
    height_in.setText("" + (int) ProfileAccessor.getHeight() % 12);
    final EditText weight_lbs = (EditText) dialog.findViewById(R.id.weight_lbs);
    weight_lbs.setText(ProfileAccessor.getWeight() + "");
    final EditText age_yrs = (EditText) dialog.findViewById(R.id.age_yrs);
    age_yrs.setText(ProfileAccessor.getAge() + "");
    final RadioButton male = (RadioButton) dialog.findViewById(R.id.male);
    final RadioButton female = (RadioButton) dialog.findViewById(R.id.female);
    if (ProfileAccessor.getSex().equals("male")) {
        male.setChecked(true);
        female.setChecked(false);
    } else {
        male.setChecked(false);
        female.setChecked(true);
    }
    final EditText[] et = { username, height_ft, height_in, weight_lbs, age_yrs };
    ok_button.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            String user_string = username.getText().toString();
            String height_ft_string = height_ft.getText().toString();
            String height_in_string = height_in.getText().toString();
            Log.d("TEXT", height_in_string);
            String weight_lbs_string = weight_lbs.getText().toString();
            String age_yrs_string = age_yrs.getText().toString();
            boolean are_any_empty = false;
            for (EditText e : et) {
                String str = e.getText().toString();
                if (str == null || str.length() == 0)
                    are_any_empty = true;
            }
            if (!are_any_empty) {
                int height = Integer.parseInt(height_ft_string) * 12 + Integer.parseInt(height_in_string);
                String sex;
                if (male.isChecked())
                    sex = "male";
                else
                    sex = "female";
                //ProfileAccessor.createNewProfile(user_string, height, Integer.parseInt(weight_lbs_string), sex, Integer.parseInt(age_yrs_string));
                ProfileAccessor.changeUsername(user_string);
                //actionBar.setTitle(getString(R.string.app_name) + ": " + ProfileAccessor.getUsername());
                ProfileAccessor.changeHeight(height);
                ProfileAccessor.changeWeight(Double.parseDouble(weight_lbs_string));
                ProfileAccessor.changeSex(sex);
                ProfileAccessor.changeAge(Integer.parseInt(age_yrs_string));
                dialog.dismiss();
            }
        }
    });

    dialog.show();
}

From source file:com.partypoker.poker.engagement.reach.activity.EngagementPollActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    /* Init layout */
    super.onCreate(savedInstanceState);

    /* If no content, nothing to do, super class already called finish */
    if (mContent == null)
        return;/*from  www . j av  a 2  s .  c  o  m*/

    /* Render questions */
    LinearLayout questionsLayout = getView("questions");
    JSONArray questions = mContent.getQuestions();
    LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    try {
        for (int i = 0; i < questions.length(); i++) {
            /* Get question */
            JSONObject question = questions.getJSONObject(i);

            /* Inflate question layout */
            LinearLayout questionLayout = (LinearLayout) layoutInflater
                    .inflate(getLayoutId("engagement_poll_question"), null);

            /* Set question's title */
            TextView questionTitle = (TextView) questionLayout.findViewById(getId("question_title"));
            questionTitle.setText(question.getString("title"));

            /* Set choices */
            RadioGroup choicesView = (RadioGroup) questionLayout.findViewById(getId("choices"));
            choicesView.setTag(question);
            JSONArray choices = question.getJSONArray("choices");
            int choiceViewId = 0;
            for (int j = 0; j < choices.length(); j++) {
                /* Get choice */
                JSONObject choice = choices.getJSONObject(j);

                /* Inflate choice layout */
                RadioButton choiceView = (RadioButton) layoutInflater
                        .inflate(getLayoutId("engagement_poll_choice"), null);

                /* Each choice is a radio button */
                choiceView.setId(choiceViewId++);
                choiceView.setTag(choice.getString("id"));
                choiceView.setText(choice.getString("title"));
                choiceView.setChecked(choice.optBoolean("isDefault"));
                choicesView.addView(choiceView);
            }

            /* Add to parent layouts */
            questionsLayout.addView(questionLayout);

            /* Watch state */
            mRadioGroups.add(choicesView);
            choicesView.setOnCheckedChangeListener(mRadioGroupListener);
        }
    } catch (JSONException jsone) {
        /* Drop on parsing error */
        mContent.dropContent(this);
        finish();
        return;
    }

    /* Disable action if a choice is not selected */
    updateActionState();
}

From source file:com.z299studio.pb.ActionDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (Application.getInstance() == null || Application.getInstance().getAccountManager() == null) {
        return null;
    }//from   ww  w .j  a va 2s .com
    View rootView;
    int[] layouts = { R.layout.dialog_authenticate, R.layout.dialog_export, R.layout.dialog_import,
            R.layout.dialog_reset_pwd, R.layout.dialog_credits, R.layout.dialog_license,
            R.layout.dialog_authenticate };
    rootView = inflater.inflate(layouts[mDlgType], container, false);
    mOkButton = (Button) rootView.findViewById(R.id.ok);
    if (mOkButton != null) {
        mOkButton.setOnClickListener(this);
    }
    View cancel = rootView.findViewById(R.id.cancel);
    if (cancel != null) {
        cancel.setOnClickListener(this);
    }
    if (mDlgType != ACTION_EXPORT && mOkButton != null) {
        mOkButton.setEnabled(false);
        mOkButton.setAlpha(0.4f);
    }
    switch (mDlgType) {
    case ACTION_EXPORT:
    case ACTION_IMPORT:
        Spinner spinner = (Spinner) rootView.findViewById(R.id.spinner);
        ArrayAdapter<CharSequence> spinnerAdapter = ArrayAdapter.createFromResource(getActivity(),
                mDlgType == ACTION_EXPORT ? R.array.file_types : R.array.file_types_import,
                android.R.layout.simple_spinner_dropdown_item);
        spinner.setAdapter(spinnerAdapter);
        spinner.setSelection(mFileType);
        spinner.setOnItemSelectedListener(this);
        if (mDlgType == ACTION_IMPORT) {
            int ids[] = { R.id.ignore, R.id.keepall, R.id.overwrite };
            for (int i = 0; i < ids.length; ++i) {
                RadioButton rb = (RadioButton) rootView.findViewById(ids[i]);
                rb.setOnClickListener(this);
                if (i == mOption) {
                    rb.setChecked(true);
                }
            }
            mSelectButton = (Button) rootView.findViewById(R.id.select);
            mSelectButton.setOnClickListener(this);
        }
        break;
    case ACTION_AUTHENTICATE2:
        ((TextView) rootView.findViewById(R.id.auth_desc)).setText(R.string.diff_pwd);
        ((Button) rootView.findViewById(R.id.cancel)).setText(R.string.discard);
        // no break to use the logic of authenticate
    case ACTION_AUTHENTICATE:
        mPasswordEdits[1] = (EditText) rootView.findViewById(R.id.et_password);
        mPasswordEdits[1].addTextChangedListener(this);
        break;

    case ACTION_RESET_PWD:
        int ids[] = { R.id.et_cur_pwd, R.id.et_password, R.id.et_confirm };
        for (int i = 0; i < ids.length; ++i) {
            mPasswordEdits[i] = (EditText) rootView.findViewById(ids[i]);
            mPasswordEdits[i].addTextChangedListener(this);
        }
        break;

    case ACTION_CREDITS:
        rootView.findViewById(R.id.cancel).setOnClickListener(this);
        TextView tv = (TextView) rootView.findViewById(R.id.testers);
        tv.setText(R.string.cc_yhc);
        tv = (TextView) rootView.findViewById(R.id.translators);
        String translators = String.format(Locale.getDefault(), "%s: %s\n%s: %s\n%s: %s",
                getString(R.string.lang_fr), getString(R.string.cc_xcx), getString(R.string.lang_es),
                getString(R.string.cc_jh), getString(R.string.lang_zhtw), getString(R.string.cc_qqz));
        tv.setText(translators);
        break;

    case ACTION_LICENSE:
        WebView wv = (WebView) rootView.findViewById(R.id.licence_page);
        wv.loadUrl("file:///android_asset/licence.html");
        break;
    }
    return rootView;
}

From source file:com.androzic.route.RouteStart.java

public void updateRouteInfo(View view) {
    if (route.length() < 2) {
        Toast.makeText(getActivity(), R.string.err_shortroute, Toast.LENGTH_LONG).show();
        // "Close" fragment
        getFragmentManager().popBackStack();
        return;/*from   ww w  .  j av  a 2  s  .  c om*/
    }

    TextView name = (TextView) view.findViewById(R.id.name);
    name.setText(route.name);

    Waypoint start = route.getWaypoint(0);
    Waypoint end = route.getWaypoint(route.length() - 1);

    RadioButton forward = (RadioButton) view.findViewById(R.id.forward);
    RadioButton reverse = (RadioButton) view.findViewById(R.id.reverse);

    Resources resources = getResources();
    String from = resources.getString(R.string.from_start);
    String to = resources.getString(R.string.start_to_end);
    forward.setText(from + " " + start.name + " " + to + " " + end.name);
    reverse.setText(from + " " + end.name + " " + to + " " + start.name);

    forward.setChecked(true);
}

From source file:org.mariotaku.twidere.fragment.support.card.CardPollFragment.java

private void displayPoll(final ParcelableCardEntity card, final ParcelableStatus status) {
    if (card == null || status == null)
        return;//  www . ja  va  2  s  . co m
    mCard = card;
    final int choicesCount = getChoicesCount(card);
    int votesSum = 0;
    final boolean countsAreFinal = card.getAsBoolean("counts_are_final", false);
    final int selectedChoice = card.getAsInteger("selected_choice", -1);
    final Date endDatetimeUtc = card.getAsDate("end_datetime_utc", new Date());
    final boolean hasChoice = selectedChoice != -1;
    final boolean isMyPoll = status.account_id == status.user_id;
    final boolean showResult = countsAreFinal || isMyPoll || hasChoice;
    for (int i = 0; i < choicesCount; i++) {
        final int choiceIndex = i + 1;
        votesSum += card.getAsInteger("choice" + choiceIndex + "_count", 0);
    }

    final View.OnClickListener clickListener = new View.OnClickListener() {
        private boolean clickedChoice;

        @Override
        public void onClick(View v) {
            if (hasChoice || clickedChoice)
                return;
            for (int i = 0, j = mPollContainer.getChildCount(); i < j; i++) {
                final View pollItem = mPollContainer.getChildAt(i);
                pollItem.setClickable(false);
                clickedChoice = true;
                final RadioButton choiceRadioButton = (RadioButton) pollItem.findViewById(R.id.choice_button);
                final boolean checked = v == pollItem;
                choiceRadioButton.setChecked(checked);
                if (checked) {
                    final CardDataMap cardData = new CardDataMap();
                    cardData.putLong("original_tweet_id", status.id);
                    cardData.putString("card_uri", card.url);
                    cardData.putString("cards_platform", TwitterAPIFactory.CARDS_PLATFORM_ANDROID_12);
                    cardData.putString("response_card_name", card.name);
                    cardData.putString("selected_choice", String.valueOf(i + 1));
                    TaskRunnable<CardDataMap, ParcelableCardEntity, CardPollFragment> task = new TaskRunnable<CardDataMap, ParcelableCardEntity, CardPollFragment>() {

                        @Override
                        public void callback(CardPollFragment handler, ParcelableCardEntity result) {
                            handler.displayPoll(result, status);
                        }

                        @Override
                        public ParcelableCardEntity doLongOperation(CardDataMap cardDataMap)
                                throws InterruptedException {
                            final TwitterCaps caps = TwitterAPIFactory.getTwitterInstance(getContext(),
                                    card.account_id, true, true, TwitterCaps.class);
                            if (caps == null)
                                return null;
                            try {
                                final CardEntity cardEntity = caps.sendPassThrough(cardDataMap).getCard();
                                return ParcelableCardEntity.fromCardEntity(cardEntity, card.account_id);
                            } catch (TwitterException e) {
                                Log.w(LOGTAG, e);
                            }
                            return null;
                        }
                    };
                    task.setParams(cardData);
                    AsyncManager.runBackgroundTask(task);
                }
            }
        }
    };

    final int color = ContextCompat.getColor(getContext(), R.color.material_light_blue_a200);
    final float radius = getResources().getDimension(R.dimen.element_spacing_small);
    for (int i = 0; i < choicesCount; i++) {
        final View pollItem = mPollContainer.getChildAt(i);

        final TextView choicePercentView = (TextView) pollItem.findViewById(R.id.choice_percent);
        final TextView choiceLabelView = (TextView) pollItem.findViewById(R.id.choice_label);
        final RadioButton choiceRadioButton = (RadioButton) pollItem.findViewById(R.id.choice_button);

        final int choiceIndex = i + 1;
        final String label = card.getAsString("choice" + choiceIndex + "_label", null);
        final int value = card.getAsInteger("choice" + choiceIndex + "_count", 0);
        if (label == null)
            throw new NullPointerException();
        final float choicePercent = votesSum == 0 ? 0 : value / (float) votesSum;
        choiceLabelView.setText(label);
        choicePercentView.setText(String.format("%d%%", Math.round(choicePercent * 100)));

        pollItem.setOnClickListener(clickListener);

        final boolean isSelected = selectedChoice == choiceIndex;

        if (showResult) {
            choicePercentView.setVisibility(View.VISIBLE);
            choiceRadioButton.setVisibility(hasChoice && isSelected ? View.VISIBLE : View.INVISIBLE);
            ViewSupport.setBackground(choiceLabelView, new PercentDrawable(choicePercent, radius, color));
        } else {
            choicePercentView.setVisibility(View.GONE);
            choiceRadioButton.setVisibility(View.VISIBLE);
            ViewSupport.setBackground(choiceLabelView, null);
        }

        choiceRadioButton.setChecked(isSelected);
        pollItem.setClickable(selectedChoice == -1);

    }

    final String nVotes = getResources().getQuantityString(R.plurals.N_votes, votesSum, votesSum);

    final CharSequence timeLeft = DateUtils.getRelativeTimeSpanString(getContext(), endDatetimeUtc.getTime(),
            true);
    mPollSummary.setText(getString(R.string.poll_summary_format, nVotes, timeLeft));
}

From source file:com.blueverdi.rosietheriveter.MoreFragment.java

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    setRetainInstance(false);//from ww  w . j a  va2s.  co  m
    thisFragment = this;
    myTour = new MySqliteHelperMyTour(getActivity());
    networkAvailable = Utils.isNetworkAvailable(getActivity());
    buildSitesList();
    view = inflater.inflate(R.layout.more_fragment, container, false);
    viewContainer = (LinearLayout) view.findViewById(R.id.view_container);
    RadioGroup radioGroup = (RadioGroup) view.findViewById(R.id.radioGroup1);
    // implementation without nested fragments
    // first initialize the gallery view
    // ---------------------------------
    listLayout = (LinearLayout) inflater.inflate(R.layout.site_gallery_view, viewContainer, false);
    Display display = ((WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE))
            .getDefaultDisplay();
    int rotation = display.getRotation();
    switch (rotation) {
    case Surface.ROTATION_0:
    case Surface.ROTATION_180:
        portrait = true;
        arrayLayout = R.layout.site_portrait;
        break;
    case Surface.ROTATION_90:
    case Surface.ROTATION_270:
        portrait = false;
        arrayLayout = R.layout.site_landscape;
        break;
    }
    ListView listview = (ListView) listLayout.findViewById(R.id.siteListView);

    // now initialize the map view 
    // --------------------------
    mapLayout = (LinearLayout) inflater.inflate(R.layout.site_map_view, viewContainer, false);
    try {
        MapsInitializer.initialize(this.getActivity());
    } catch (Exception e) {
        e.printStackTrace();

    }
    mapView = (MapView) mapLayout.findViewById(R.id.siteMap);
    mapView.onCreate(savedInstanceState);
    mapView.getMapAsync(new OnMapReadyCallback() {
        @Override
        public void onMapReady(GoogleMap googleMap) {
            map = googleMap;
            map.getUiSettings().setMyLocationButtonEnabled(false);
            if (!networkAvailable) {
                thisFragment.getActivity().runOnUiThread(new Runnable() {

                    @Override
                    public void run() {
                        Toast.makeText(getActivity(), getString(R.string.internet_required), Toast.LENGTH_LONG)
                                .show();

                    }
                });
            }

            map.setOnCameraChangeListener(new OnCameraChangeListener() {

                @Override
                public void onCameraChange(CameraPosition arg0) {
                    map.setOnCameraChangeListener(null);
                    CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngBounds(SITES, 0);
                    if (networkAvailable) {
                        map.animateCamera(cameraUpdate);
                    } else {
                        map.moveCamera(cameraUpdate);
                    }
                }
            });
            markers = new HashMap<String, Site>();
            for (Site s : sites) {
                LatLng ll = new LatLng(Double.parseDouble(s.getString(Site.LATITUDE)),
                        Double.parseDouble(s.getString(Site.LONGITUDE)));
                Marker marker = map.addMarker(new MarkerOptions().position(ll).title(s.getString(Site.NAME)));
                markers.put(marker.getId(), s);
            }
            map.setOnMarkerClickListener(new OnMarkerClickListener() {
                @Override
                public boolean onMarkerClick(Marker marker) {
                    Site s = markers.get(marker.getId());
                    Intent i = new Intent(getActivity(), SiteActivity.class);
                    i.putExtra(Site.PARCEL_NAME, s);
                    startActivity(i);
                    getActivity().overridePendingTransition(R.anim.zoom_in, 0);
                    return true;
                }
            });
        }
    });
    try {
        container.removeAllViews();
    } catch (Exception e) {
        MyLog.d(TAG, "container evaporated inside onCreateView");
        return view;
    }
    if (startInMapView) {
        RadioButton rb = (RadioButton) view.findViewById(R.id.radioMapView);
        rb.setChecked(true);
        setMap();
    } else {
        setGallery();
    }
    radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            if (checkedId == R.id.radioListView) {
                setGallery();
            } else {
                Toast.makeText(getActivity(), getString(R.string.getting_map), Toast.LENGTH_LONG).show();
                setMap();
            }
        }
    });
    return view;
}

From source file:org.mariotaku.twidere.fragment.card.CardPollFragment.java

private void displayPoll(final ParcelableCardEntity card, final ParcelableStatus status) {
    final Context context = getContext();
    if (card == null || status == null || context == null)
        return;//from  w  w w  .  j  a  va 2 s  . co m
    mCard = card;
    final int choicesCount = getChoicesCount(card);
    int votesSum = 0;
    final boolean countsAreFinal = ParcelableCardEntityUtils.getAsBoolean(card, "counts_are_final", false);
    final int selectedChoice = ParcelableCardEntityUtils.getAsInteger(card, "selected_choice", -1);
    final Date endDatetimeUtc = ParcelableCardEntityUtils.getAsDate(card, "end_datetime_utc", new Date());
    final boolean hasChoice = selectedChoice != -1;
    final boolean isMyPoll = status.account_key.equals(status.user_key);
    final boolean showResult = countsAreFinal || isMyPoll || hasChoice;
    for (int i = 0; i < choicesCount; i++) {
        final int choiceIndex = i + 1;
        votesSum += ParcelableCardEntityUtils.getAsInteger(card, "choice" + choiceIndex + "_count", 0);
    }

    final View.OnClickListener clickListener = new View.OnClickListener() {
        private boolean clickedChoice;

        @Override
        public void onClick(View v) {
            if (hasChoice || clickedChoice)
                return;
            for (int i = 0, j = mPollContainer.getChildCount(); i < j; i++) {
                final View pollItem = mPollContainer.getChildAt(i);
                pollItem.setClickable(false);
                clickedChoice = true;
                final RadioButton choiceRadioButton = (RadioButton) pollItem.findViewById(R.id.choice_button);
                final boolean checked = v == pollItem;
                choiceRadioButton.setChecked(checked);
                if (checked) {
                    final CardDataMap cardData = new CardDataMap();
                    cardData.putLong("original_tweet_id", NumberUtils.toLong(status.id));
                    cardData.putString("card_uri", card.url);
                    cardData.putString("cards_platform", MicroBlogAPIFactory.CARDS_PLATFORM_ANDROID_12);
                    cardData.putString("response_card_name", card.name);
                    cardData.putString("selected_choice", String.valueOf(i + 1));
                    AbstractTask<CardDataMap, ParcelableCardEntity, CardPollFragment> task = new AbstractTask<CardDataMap, ParcelableCardEntity, CardPollFragment>() {

                        @Override
                        public void afterExecute(CardPollFragment handler, ParcelableCardEntity result) {
                            handler.displayAndReloadPoll(result, status);
                        }

                        @Override
                        public ParcelableCardEntity doLongOperation(CardDataMap cardDataMap) {
                            final Context context = getContext();
                            if (context == null)
                                return null;
                            final TwitterCaps caps = MicroBlogAPIFactory.getInstance(context, card.account_key,
                                    true, true, TwitterCaps.class);
                            if (caps == null)
                                return null;
                            try {
                                final CardEntity cardEntity = caps.sendPassThrough(cardDataMap).getCard();
                                return ParcelableCardEntityUtils.fromCardEntity(cardEntity, card.account_key);
                            } catch (MicroBlogException e) {
                                Log.w(LOGTAG, e);
                            }
                            return null;
                        }
                    };
                    task.setResultHandler(CardPollFragment.this);
                    task.setParams(cardData);
                    TaskStarter.execute(task);
                }
            }
        }
    };

    final int color = ContextCompat.getColor(context, R.color.material_light_blue_a200);
    final float radius = getResources().getDimension(R.dimen.element_spacing_small);
    for (int i = 0; i < choicesCount; i++) {
        final View pollItem = mPollContainer.getChildAt(i);

        final TextView choicePercentView = (TextView) pollItem.findViewById(R.id.choice_percent);
        final TextView choiceLabelView = (TextView) pollItem.findViewById(R.id.choice_label);
        final RadioButton choiceRadioButton = (RadioButton) pollItem.findViewById(R.id.choice_button);

        final int choiceIndex = i + 1;
        final String label = ParcelableCardEntityUtils.getAsString(card, "choice" + choiceIndex + "_label",
                null);
        final int value = ParcelableCardEntityUtils.getAsInteger(card, "choice" + choiceIndex + "_count", 0);
        if (label == null)
            throw new NullPointerException();
        final float choicePercent = votesSum == 0 ? 0 : value / (float) votesSum;
        choiceLabelView.setText(label);
        choicePercentView.setText(String.format(Locale.US, "%d%%", Math.round(choicePercent * 100)));

        pollItem.setOnClickListener(clickListener);

        final boolean isSelected = selectedChoice == choiceIndex;

        if (showResult) {
            choicePercentView.setVisibility(View.VISIBLE);
            choiceRadioButton.setVisibility(hasChoice && isSelected ? View.VISIBLE : View.INVISIBLE);
            ViewSupport.setBackground(choiceLabelView, new PercentDrawable(choicePercent, radius, color));
        } else {
            choicePercentView.setVisibility(View.GONE);
            choiceRadioButton.setVisibility(View.VISIBLE);
            ViewSupport.setBackground(choiceLabelView, null);
        }

        choiceRadioButton.setChecked(isSelected);
        pollItem.setClickable(selectedChoice == -1);

    }

    final String nVotes = getResources().getQuantityString(R.plurals.N_votes, votesSum, votesSum);

    final CharSequence timeLeft = DateUtils.getRelativeTimeSpanString(context, endDatetimeUtc.getTime(), true);
    mPollSummary.setText(getString(R.string.poll_summary_format, nVotes, timeLeft));
}

From source file:com.physphil.android.unitconverterultimate.fragments.ConversionFragment.java

/**
 * Create Radio Button to display in group
 *
 * @param u       unit which the button represents
 * @param checked if the button is checked or not
 * @return RadioButton to display//  w  w  w  . j  a  v a  2  s  .  co  m
 */
private RadioButton getRadioButton(Unit u, boolean checked) {
    RadioButton btn = (RadioButton) LayoutInflater.from(getActivity()).inflate(R.layout.unit_radio_button,
            null);
    btn.setId(u.getId());
    btn.setTag(u);
    btn.setText(u.getLabelResource());
    btn.setChecked(checked);
    return btn;
}

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

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

    // Init number pickers
    final RadioButton rbF = (RadioButton) rootView.findViewById(R.id.rbFade);
    final RadioButton rbRainbow = (RadioButton) rootView.findViewById(R.id.rbRainbow);
    final RadioButton rbRainbowC = (RadioButton) rootView.findViewById(R.id.rbRainbowCircle);

    npDelay = (NumberPicker) rootView.findViewById(R.id.npDelay);
    npDelay.setMaxValue(30);/*from  w  w w.  j a v a 2  s  .  co  m*/
    npDelay.setMinValue(1);
    //npDelay.setWrapSelectorWheel(false);
    npDelay.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
        @Override
        public void onValueChange(NumberPicker numberPicker, int i, int i2) {
            rbRainbow.setChecked(false);
            rbRainbowC.setChecked(false);
            rbF.setChecked(true);

        }
    });

    npNumber = (NumberPicker) rootView.findViewById(R.id.npNumber);
    npNumber.setMaxValue(10);
    npNumber.setMinValue(1);
    //npNumber.setWrapSelectorWheel(false);
    npNumber.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
        @Override
        public void onValueChange(NumberPicker numberPicker, int i, int i2) {
            rbRainbow.setChecked(false);
            rbRainbowC.setChecked(false);
            rbF.setChecked(true);
        }
    });

    return rootView;
}

From source file:pl.poznan.put.cs.ify.app.ui.InitializedRecipeDialog.java

private View initField(Entry<String, YParam> entry, LayoutInflater inflater) {
    ParamField v = null;//from  w w  w.j ava 2s  .c om
    String name = entry.getKey();
    YParam value = entry.getValue();
    TextView nameTextView;
    switch (value.getType()) {
    case Integer:
        v = (ParamField) inflater.inflate(R.layout.field_integer, null);
        EditText integerET = (EditText) v.findViewById(R.id.field_integer);
        if (value.getValue() != null) {
            integerET.setText(value.getValue() + "");
        }
        integerET.setEnabled(false);
        break;
    case String:
        v = (ParamField) inflater.inflate(R.layout.field_string, null);
        EditText stringET = (EditText) v.findViewById(R.id.field_string);
        if (value.getValue() != null) {
            stringET.setText(value.getValue() + "");
        }
        stringET.setEnabled(false);
        break;
    case Position:
        v = (ParamField) inflater.inflate(R.layout.field_position, null);
        break;
    case Boolean:
        v = (ParamField) inflater.inflate(R.layout.field_boolean, null);
        RadioButton trueButton = (RadioButton) v.findViewById(R.id.field_boolean_yes);
        trueButton.setEnabled(false);
        RadioButton falseButton = (RadioButton) v.findViewById(R.id.field_boolean_no);
        falseButton.setEnabled(false);
        boolean defaultBool = (Boolean) value.getValue();
        if (defaultBool) {
            trueButton.setChecked(true);
            falseButton.setChecked(false);
        } else {
            falseButton.setChecked(true);
            trueButton.setChecked(false);
        }
        break;
    default:
        v = (ParamField) inflater.inflate(R.layout.field_string, null);
        EditText defaultET = (EditText) v.findViewById(R.id.field_string);
        if (value.getValue() != null) {
            defaultET.setText(value.getValue() + "");
        }
        defaultET.setEnabled(false);
        break;
    }
    nameTextView = (TextView) v.findViewById(R.id.field_name);
    nameTextView.setText(name);
    v.setYParam(value);
    v.setName(name);
    return v;
}