Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- *
- * Sets the Radiogroup button values to the desired.
- * @Author: Daryl
- * @Date: 26/01/2015
- * @Prerequisite: android.widget.* | java.util.ArrayList | org.json.*
- * @Parameters: RadioGroup , JSONArray
- *
- */
- public void setRadioGroupValues(RadioGroup radioGroup , JSONArray valueArray, Boolean disableEmptyBoxes){
- int count = radioGroup.getChildCount();
- int arraylength = valueArray.length();
- //ArrayList<RadioButton> listOfRadioButtons = new ArrayList<RadioButton>();
- for (int i=0;i<count;i++) {
- View button = radioGroup.getChildAt(i);
- if (button instanceof RadioButton) {
- // listOfRadioButtons.add((RadioButton)o);
- logger.info("id:"+i+" "+((RadioButton) button).getText().toString());
- try{
- ((RadioButton) button).setText(((i > (arraylength - 1)) || (arraylength == 0)) ? "" : valueArray.getString(i));
- if(disableEmptyBoxes && ((RadioButton) button).getText().toString().isEmpty()){
- ((RadioButton) button).setVisibility(View.GONE);
- }else{
- ((RadioButton) button).setVisibility(View.VISIBLE);
- }
- }catch (Exception e) {
- logger.error("JSON parsing error " + e);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement