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:kn.uni.gis.foxhunt.GameActivity.java

private void enableConnectionButton(final int id) {
    runOnUiThread(new Runnable() {
        @Override//from  w w  w  . ja v a2  s . co m
        public void run() {
            RadioButton button = ((RadioButton) findViewById(id));
            button.setChecked(true);
        }
    });
}

From source file:fr.leicht.androideip.MainActivity.java

public void UpdateIHM(final String resultat) {
    //Dposer le Runnable dans la file d'attente de l'UI thread
    runOnUiThread(new Runnable() {
        @Override//w w w  .  j  a v a 2s .co  m
        public void run() {
            //code excut par l'UI thread
            Fragment frag = (Fragment) getSupportFragmentManager().findFragmentById(R.id.container);
            //Tab CHAUFFAGE
            if (frag != null && frag.getTag() == "Tab1") {
                TextView msgTextView = (TextView) findViewById(R.id.TextViewTempQuentin);
                msgTextView.setText("Temprature Quentin : " + Temp_Quentin.getStringValue() + " C");

                msgTextView = (TextView) findViewById(R.id.TextViewTempTim);
                msgTextView.setText("Temprature Tim : " + Temp_Tim.getStringValue() + " C");

                msgTextView = (TextView) findViewById(R.id.TextViewTempSalle);
                msgTextView.setText("Temprature Salle : " + Temp_Salle.getStringValue() + " C");

                msgTextView = (TextView) findViewById(R.id.TextViewTempVeranda);
                msgTextView.setText("Temprature Vranda : " + Temp_Veranda.getStringValue() + " C");

                msgTextView = (TextView) findViewById(R.id.textViewConsigneQuentin);
                msgTextView.setText("Consigne : " + Temp_Confort_Quentin.getStringValue("#.0") + " C");

                msgTextView = (TextView) findViewById(R.id.TextViewConsigneTim);
                msgTextView.setText("Consigne : " + Temp_Confort_Tim.getStringValue("#.0") + " C");

                msgTextView = (TextView) findViewById(R.id.TextViewConsigneSalle);
                msgTextView.setText("Consigne : " + Temp_Confort_Salle.getStringValue("#.0") + " C");

                msgTextView = (TextView) findViewById(R.id.textViewTempExt);
                msgTextView.setText("Temprature Ext : " + Temp_Ext.getStringValue("#.0") + " C");

                Switch switch1 = (Switch) findViewById(R.id.switch1);
                switch1.setChecked(Autorisation_IHM_Plancher.getBoolValue());

                switch1 = (Switch) findViewById(R.id.SwitchChaufQ);
                switch1.setChecked(BP_IHM_Chauffage_Quentin.getBoolValue());

                switch1 = (Switch) findViewById(R.id.SwitchChauffS);
                switch1.setChecked(BP_IHM_Chauffage_Salle.getBoolValue());

                switch1 = (Switch) findViewById(R.id.SwitchChaufT);
                switch1.setChecked(BP_IHM_Chauffage_Tim.getBoolValue());

            }
            //Tab Light
            if (frag != null && frag.getTag() == "Tab2") {
                RadioButton radio1 = (RadioButton) findViewById(R.id.radioButtonSSMilieu);
                radio1.setChecked(Light_SS_Milieu.getBoolValue());
                radio1 = (RadioButton) findViewById(R.id.radioButtonChenil);
                radio1.setChecked(Light_SS_Chenil.getBoolValue());
                radio1 = (RadioButton) findViewById(R.id.radioButtonGarage);
                radio1.setChecked(Light_SS_Garage.getBoolValue());
                Switch switch1 = (Switch) findViewById(R.id.switchLightDevant);
                switch1.setChecked(Light_Devant.getBoolValue());
                switch1.setText("Lumire Devant : " + Time_Reste_Light_Devant.getStringValue() + " S");

            }
            //Tab Divers
            if (frag != null && frag.getTag() == "Tab3") {
                RadioButton radio2 = (RadioButton) findViewById(R.id.radioButtonEJP);
                radio2.setChecked(EJP.getBoolValue());

            }
            setTitle("AndroidEIP  " + resultat);
        }
    });
}

From source file:layout.BeaconTabFragment.java

/**
 * Sets up the advertising tx power view. It is initially disabled. It is enabled by clicking
 * on the radio button in the UI. This opens a dialog to confirm that the user really wants to
 * change the advertising radio tx power. After this the advertising interval can be configured.
 * A list pops up where the user can choose which value they want to be broadcast as the
 * advertising tx power./*from w  w w  .  j  ava2 s.  co m*/
 */
private void setUpAdvertisedTxPower(final View v) {
    if (advTxPower != null) {
        LinearLayout advTxPowerContainer = (LinearLayout) v.findViewById(R.id.change_adv_tx_slot);

        final TextView advTxPowerView = (TextView) v.findViewById(R.id.adv_tx_power);
        advTxPowerView.setText(advTxPower);
        advTxPowerView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View view, boolean hasFocus) {
                if (!hasFocus) {
                    String newAdvTxPower = advTxPowerView.getText().toString();
                    if (newAdvTxPower.length() == 0) {
                        advTxPowerView.setText(advTxPower);
                    }

                } else {
                    advTxPowerChanged = true;
                }
            }
        });

        advTxPowerContainer.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                advTxPowerChanged = true;
                final String[] possibleValues = Utils.generateArrayWithStringValuesInRange(
                        Utils.findMinValue(capabilities.getSupportedTxPowers()) - 5,
                        Utils.findMaxValue(capabilities.getSupportedTxPowers()) + 5);
                new AlertDialog.Builder(getActivity()).setTitle("Choose advertising tx power:")
                        .setItems(possibleValues, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialogInterface, int i) {
                                advTxPower = possibleValues[i];
                                advTxPowerView.setText(possibleValues[i]);
                            }
                        }).show();
            }
        });

        UiUtils.disableAllChildren(advTxPowerContainer);

        final RadioButton enableChangeAdvTxPowerButton = (RadioButton) v
                .findViewById(R.id.change_slot_adv_tx_power);
        enableChangeAdvTxPowerButton.setChecked(false);
        enableChangeAdvTxPowerButton.setOnClickListener(new View.OnClickListener() {
            private boolean enabled = false;

            @Override
            public void onClick(View view) {
                if (enabled) {
                    UiUtils.disableAllChildren(v.findViewById(R.id.change_adv_tx_slot));
                    enableChangeAdvTxPowerButton.setChecked(false);
                    enabled = false;
                } else {
                    ConfirmationDialog.confirm("Change Advertising Interval",
                            "Are you sure " + "you want to change the advertising interval of this beacon?",
                            "YES", "NO", getActivity(), new ConfirmationDialog.ConfirmationListener() {
                                @Override
                                public void confirm() {
                                    UiUtils.enableAllChildren(v.findViewById(R.id.change_adv_tx_slot));
                                    enableChangeAdvTxPowerButton.setChecked(true);
                                    enabled = true;
                                }

                                @Override
                                public void cancel() {
                                    enableChangeAdvTxPowerButton.setChecked(false);
                                    enabled = false;
                                }
                            });
                }
            }
        });
    }
}

From source file:com.hardcopy.vcontroller.fragments.AddBrokerFragment.java

private void restoreUserInput() {
    if (mEditClientId == null)
        return;//from  w  w  w .  j av  a 2  s . co m
    String clientId = mUserInput.getString(Constants.clientId, Constants.empty);
    mEditClientId.setText(clientId);
    String server = mUserInput.getString(Constants.server, Constants.empty);
    mEditServerUri.setText(server);
    String port = mUserInput.getString(Constants.port, Integer.toString(Constants.defaultPort));
    mEditPort.setText(port);

    mCheckCleanSession.setChecked(mUserInput.getBoolean(Constants.cleanSession, Constants.defaultCleanSession));
    String username = mUserInput.getString(Constants.username, Constants.empty);
    mEditUserName.setText(username);
    String password = mUserInput.getString(Constants.password, Constants.empty);
    mEditPassword.setText(password);

    mCheckSsl.setChecked(mUserInput.getBoolean(Constants.ssl, Constants.defaultSsl));
    String sslkey = mUserInput.getString(Constants.ssl_key, Constants.empty);
    mEditSslKeyPath.setText(sslkey);
    mEditTimeOut.setText(Integer.toString(mUserInput.getInt(Constants.timeout, Constants.defaultTimeOut)));
    mEditKeepAlive
            .setText(Integer.toString(mUserInput.getInt(Constants.keepalive, Constants.defaultKeepAlive)));

    String topic = mUserInput.getString(Constants.topic, Constants.empty);
    mEditTopic.setText(topic);
    String message = mUserInput.getString(Constants.message, Constants.empty);
    mEditMessage.setText(message);
    RadioButton wRadio = (RadioButton) mRadioQos
            .getChildAt(mUserInput.getInt(Constants.qos, Constants.defaultQos));
    wRadio.setChecked(true);
    mCheckRetained.setChecked(mUserInput.getBoolean(Constants.retained, Constants.defaultRetained));
}

From source file:com.lm.im_huanxin.emoji.EmojiPageFragment.java

protected void initWidget(View rootView) {
    mPagerFace = (ViewPager) rootView.findViewById(R.id.frag_pager_face);
    pagePointLayout = (LinearLayout) rootView.findViewById(R.id.frag_point);

    int total = datas.size();
    int pages = total / ITEM_PAGE_COUNT + (total % ITEM_PAGE_COUNT == 0 ? 0 : 1);

    allPageViews = new GridView[pages];
    pointViews = new RadioButton[pages];

    for (int x = 0; x < pages; x++) {
        int start = x * ITEM_PAGE_COUNT;
        int end = (start + ITEM_PAGE_COUNT) > total ? total : (start + ITEM_PAGE_COUNT);
        final List<Emojicon> itemDatas = datas.subList(start, end);
        GridView view = new GridView(aty);
        EmojiAdapter faceAdapter = new EmojiAdapter(view, itemDatas);

        view.setNumColumns(7);//from   ww  w .  jav a2  s.  c o  m
        view.setHorizontalSpacing(1);
        view.setVerticalSpacing(1);
        view.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
        view.setCacheColorHint(0);
        view.setPadding(2, 0, 2, 0);
        view.setBackgroundResource(android.R.color.transparent);
        view.setSelector(android.R.color.transparent);
        view.setVerticalScrollBarEnabled(false);
        view.setGravity(Gravity.CENTER);
        view.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
                FrameLayout.LayoutParams.WRAP_CONTENT));
        view.setAdapter(faceAdapter);

        view.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                if (listener != null) {
                    Emojicon emoji = itemDatas.get(position);
                    if (DisplayRules.isDeleteEmojicon(emoji)) {
                        listener.selectedBackSpace(emoji);
                    } else {
                        listener.selectedEmoji(emoji);
                    }
                }
            }
        });
        allPageViews[x] = view;

        RadioButton tip = new RadioButton(aty);
        tip.setBackgroundResource(R.drawable.selector_bg_tip);
        RadioGroup.LayoutParams layoutParams = new RadioGroup.LayoutParams(8, 8);
        layoutParams.leftMargin = 10;
        pagePointLayout.addView(tip, layoutParams);
        if (x == 0) {
            tip.setChecked(true);
        }
        pointViews[x] = tip;
    }

    PagerAdapter facePagerAdapter = new FacePagerAdapter(allPageViews);
    mPagerFace.setAdapter(facePagerAdapter);
    mPagerFace.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageSelected(int index) {
            pointViews[index].setChecked(true);
        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {
        }

        @Override
        public void onPageScrollStateChanged(int arg0) {
        }
    });
}

From source file:com.app.sample.chatting.data.emoji.EmojiPageFragment.java

@Override
protected void initWidget(View rootView) {
    super.initWidget(rootView);
    mPagerFace = (ViewPager) rootView.findViewById(R.id.frag_pager_face);
    pagePointLayout = (LinearLayout) rootView.findViewById(R.id.frag_point);

    int total = datas.size();
    int pages = total / ITEM_PAGE_COUNT + (total % ITEM_PAGE_COUNT == 0 ? 0 : 1);

    allPageViews = new GridView[pages];
    pointViews = new RadioButton[pages];

    for (int x = 0; x < pages; x++) {
        int start = x * ITEM_PAGE_COUNT;
        int end = (start + ITEM_PAGE_COUNT) > total ? total : (start + ITEM_PAGE_COUNT);
        final List<Emojicon> itemDatas = datas.subList(start, end);
        GridView view = new GridView(aty);
        EmojiAdapter faceAdapter = new EmojiAdapter(view, itemDatas);

        view.setNumColumns(7);//from w w w . j a  va  2s  .c  om
        view.setHorizontalSpacing(1);
        view.setVerticalSpacing(1);
        view.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
        view.setCacheColorHint(0);
        view.setPadding(2, 0, 2, 0);
        view.setBackgroundResource(android.R.color.transparent);
        view.setSelector(android.R.color.transparent);
        view.setVerticalScrollBarEnabled(false);
        view.setGravity(Gravity.CENTER);
        view.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
                FrameLayout.LayoutParams.WRAP_CONTENT));
        view.setAdapter(faceAdapter);

        view.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                if (listener != null) {
                    Emojicon emoji = itemDatas.get(position);
                    if (DisplayRules.isDeleteEmojicon(emoji)) {
                        listener.selectedBackSpace(emoji);
                    } else {
                        listener.selectedEmoji(emoji);
                    }
                }
            }
        });
        allPageViews[x] = view;

        RadioButton tip = new RadioButton(aty);
        tip.setBackgroundResource(R.drawable.selector_bg_tip);
        RadioGroup.LayoutParams layoutParams = new RadioGroup.LayoutParams(8, 8);
        layoutParams.leftMargin = 10;
        pagePointLayout.addView(tip, layoutParams);
        if (x == 0) {
            tip.setChecked(true);
        }
        pointViews[x] = tip;
    }

    PagerAdapter facePagerAdapter = new FacePagerAdapter(allPageViews);
    mPagerFace.setAdapter(facePagerAdapter);
    mPagerFace.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageSelected(int index) {
            pointViews[index].setChecked(true);
        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {
        }

        @Override
        public void onPageScrollStateChanged(int arg0) {
        }
    });
}

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

private View initField(Entry<String, YParam> entry, LayoutInflater inflater) {
    ParamField v = null;/* w w w.  java2 s .c  o m*/
    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() + "");
        }

        break;
    case Group:
    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() + "");
        }
        break;
    case Position:
        v = (ParamField) inflater.inflate(R.layout.field_position, null);
        v.findViewById(R.id.field_button_showmap).setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                FragmentTransaction ft = getFragmentManager().beginTransaction();
                PositionMapDialog d = new PositionMapDialog();
                ft.add(d, "MAP");
                ft.commit();
                ((PositionParamField) v.getParent()).setPositionMapDialog(d);

            }
        });
        break;
    case Boolean:
        v = (ParamField) inflater.inflate(R.layout.field_boolean, null);
        RadioButton trueButton = (RadioButton) v.findViewById(R.id.field_boolean_yes);
        RadioButton falseButton = (RadioButton) v.findViewById(R.id.field_boolean_no);
        boolean defaultBool = (Boolean) value.getValue();
        if (defaultBool) {
            trueButton.setChecked(true);
            falseButton.setChecked(false);
        } else {
            falseButton.setChecked(true);
            trueButton.setChecked(false);
        }
        break;
    case Number:
        v = (ParamField) inflater.inflate(R.layout.field_number, null);
        EditText numberET = (EditText) v.findViewById(R.id.field_number);
        if (value.getValue() != null) {
            numberET.setText(value.getValue() + "");
        }
        v.findViewById(R.id.field_pick_number).setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                FragmentTransaction ft = getFragmentManager().beginTransaction();
                NumberDialogFragment d = new NumberDialogFragment();
                ft.add(d, "NUMBER_PICKER");
                ft.commit();
                ((NumberParamField) v.getParent()).setNumberPickerFragment(d);

            }
        });
        break;
    default:
        break;
    }
    nameTextView = (TextView) v.findViewById(R.id.field_name);
    nameTextView.setText(name);
    v.setYParam(value);
    v.setName(name);
    return v;
}

From source file:com.app.sample.chatting.activity.chat.FacePageFragment.java

@Override
protected void initWidget(View rootView) {
    super.initWidget(rootView);
    mPagerFace = (ViewPager) rootView.findViewById(R.id.frag_pager_face);
    pagePointLayout = (LinearLayout) rootView.findViewById(R.id.frag_point);

    int total = datas.size();
    int pages = total / ITEM_PAGE_COUNT + (total % ITEM_PAGE_COUNT == 0 ? 0 : 1);

    allPageViews = new GridView[pages];
    pointViews = new RadioButton[pages];

    for (int x = 0; x < pages; x++) {
        int start = x * ITEM_PAGE_COUNT;
        int end = (start + ITEM_PAGE_COUNT) > total ? total : (start + ITEM_PAGE_COUNT);
        final List<Faceicon> itemDatas = datas.subList(start, end);
        GridView view = new GridView(aty);
        FaceAdapter faceAdapter = new FaceAdapter(view, itemDatas);
        view.setAdapter(faceAdapter);/*from   w  w  w  . j  av a2  s . c  o  m*/

        view.setNumColumns(4);
        view.setBackgroundColor(Color.TRANSPARENT);
        view.setHorizontalSpacing(1);
        view.setVerticalSpacing(1);
        view.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
        view.setCacheColorHint(0);
        view.setVerticalScrollBarEnabled(false);
        view.setPadding(5, 0, 5, 0);
        view.setSelector(new ColorDrawable(Color.TRANSPARENT));
        view.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
        view.setGravity(Gravity.CENTER);

        view.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                if (listener != null) {
                    listener.selectedFace(itemDatas.get(position));
                }
            }
        });
        allPageViews[x] = view;

        RadioButton tip = new RadioButton(aty);
        tip.setBackgroundResource(R.drawable.selector_bg_tip);
        RadioGroup.LayoutParams layoutParams = new RadioGroup.LayoutParams(8, 8);
        layoutParams.leftMargin = 10;
        pagePointLayout.addView(tip, layoutParams);
        if (x == 0) {
            tip.setChecked(true);
        }
        pointViews[x] = tip;
    }

    PagerAdapter facePagerAdapter = new FacePagerAdapter(allPageViews);
    mPagerFace.setAdapter(facePagerAdapter);
    mPagerFace.setOnPageChangeListener(new OnPageChangeListener() {

        @Override
        public void onPageSelected(int index) {
            pointViews[index].setChecked(true);
        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {
        }

        @Override
        public void onPageScrollStateChanged(int arg0) {
        }
    });
}

From source file:th.in.ffc.person.PersonDetailEditFragment.java

@Override
public void onLoadFinished(Loader<Cursor> arg0, Cursor c) {
    switch (arg0.getId()) {
    case 0://  www  .j a va2s . c o  m
        if (c.moveToFirst()) {
            citizenId.setText(c.getString(0));

            int id = (c.getInt(1) == 1) ? R.id.male : R.id.female;
            RadioButton btn = (RadioButton) sex.findViewById(id);
            btn.setChecked(true);

            prename.setSelection(c.getString(2));
            fname.setText(c.getString(3));
            lname.setText(c.getString(4));

            String birth = (c.getString(5));
            if (!TextUtils.isEmpty(birth)) {
                Date b = Date.newInstance(birth);
                birthday.updateDate(b);
            }

            bloodType.setSelection(c.getString(6));
            bloodRh.setSelection(c.getString(7));
            religion.setSelection(c.getString(8));
            nation.setSelectionById(c.getString(9));
            house.setSelectionById(c.getLong(10));
            allergic.setText(c.getString(11));
            origin.setSelectionById(c.getString(12));

            String sIncome = c.getString(13);
            if (!TextUtils.isEmpty(sIncome))
                income.setText(sIncome);

            tel.setText(c.getString(14));

            education.setSelection(c.getString(15));
            occupa.setSelectionById(c.getString(16));

            hno.setText(c.getString(17));
            mu.setText(c.getString(18));
            road.setText(c.getString(19));

            if (!TextUtils.isEmpty(c.getString(21)) && !TextUtils.isEmpty(c.getString(22))
                    && !TextUtils.isEmpty(c.getString(20))) {

                provcode.setSelectionById(c.getString(22));
                distcode.setSelectionById(c.getString(21),
                        "distcode =? AND provcode ='" + c.getString(22) + "'");
                subdistcode.setSelectionById(c.getString(20), "subdistcode=? AND distcode='" + c.getString(21)
                        + "' AND provcode='" + c.getString(22) + "'");

                postcode.setText(c.getString(23));
            }

        }
        break;
    case 1:
        if (c.moveToFirst()) {
            newPid = c.getInt(0) + 1;
            getFFCActivity().getSupportActionBar().setSubtitle("pid #" + newPid);

            nation.setSelectionById("99");
            origin.setSelectionById("99");
            bloodType.setSelection("O");
            religion.setSelection("01");

        }
        break;
    case 2:
        if (c.moveToFirst()) {
            if (!TextUtils.isEmpty(getPID()) && c.getString(1).equals(getPID())) {
                isUseableId = true;
                isCurrentId = true;
            } else {
                isUseableId = false;
                isCurrentId = false;
            }
        } else {
            isUseableId = true;
            isCurrentId = false;
        }
        break;
    }
}

From source file:com.ubikod.capptain.android.sdk.reach.activity.CapptainPollActivity.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;//  w  ww. ja  va 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("capptain_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("capptain_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.getBoolean("default"));
                choicesView.addView(choiceView);
            }

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

            /* Watch state */
            mRadioGroups.add(choicesView);
            choicesView.setOnCheckedChangeListener(mRadioGroupListener);
        }
    } catch (JSONException jsone) {
        /* Won't happen */
    }

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