Java Code Examples for android.widget.RadioGroup#getChildAt()

The following examples show how to use android.widget.RadioGroup#getChildAt() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SimpleNoValuesExtractor.java    From AndroidRipper with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Detect Name of the Widget
 * 
 * @param v
 *            Widget
 * @return
 */
private String detectName(View v) {
	String name = "";
	if (v instanceof TextView) {
		TextView t = (TextView) v;
		name = (t.getText() != null) ? t.getText().toString() : "";
		if (v instanceof EditText) {
			CharSequence hint = ((EditText) v).getHint();
			name = (hint == null) ? "" : hint.toString();
		}
	} else if (v instanceof RadioGroup) {
		RadioGroup g = (RadioGroup) v;
		int max = g.getChildCount();
		String text = "";
		for (int i = 0; i < max; i++) {
			View c = g.getChildAt(i);
			text = detectName(c);
			if (!text.equals("")) {
				name = text;
				break;
			}
		}
	}
	return name;
}
 
Example 2
Source File: SimpleExtractor.java    From AndroidRipper with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Detect Name of the Widget
 * 
 * @param v
 *            Widget
 * @return
 */
protected String detectName(View v) {
	String name = "";
	if (v instanceof TextView) {
		TextView t = (TextView) v;
		name = (t.getText() != null) ? t.getText().toString() : "";
		if (v instanceof EditText) {
			CharSequence hint = ((EditText) v).getHint();
			name = (hint == null) ? "" : hint.toString();
		}
	} else if (v instanceof RadioGroup) {
		RadioGroup g = (RadioGroup) v;
		int max = g.getChildCount();
		String text = "";
		for (int i = 0; i < max; i++) {
			View c = g.getChildAt(i);
			text = detectName(c);
			if (!text.equals("")) {
				name = text;
				break;
			}
		}
	}
	return name;
}
 
Example 3
Source File: ReflectionExtractor.java    From AndroidRipper with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Detect Name of the Widget
 * 
 * @param v
 *            Widget
 * @return
 */
protected String detectName(View v) {
	String name = "";
	if (v instanceof TextView) {
		TextView t = (TextView) v;
		name = (t.getText() != null) ? t.getText().toString() : "";
		if (v instanceof EditText) {
			CharSequence hint = ((EditText) v).getHint();
			name = (hint == null) ? "" : hint.toString();
		}
	} else if (v instanceof RadioGroup) {
		RadioGroup g = (RadioGroup) v;
		int max = g.getChildCount();
		String text = "";
		for (int i = 0; i < max; i++) {
			View c = g.getChildAt(i);
			text = detectName(c);
			if (!text.equals("")) {
				name = text;
				break;
			}
		}
	}
	return name;
}
 
Example 4
Source File: SimpleImageAct.java    From ZoomImageView with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_simple_image);

    ziv = (ZoomImageView) findViewById(R.id.ziv);
    ziv.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            SimpleImageAct.this.finish();
        }
    });
    group = (RadioGroup) findViewById(R.id.group);
    RadioButton child = (RadioButton) group.getChildAt(0);
    child.setChecked(true);
    ImageLoader.getInstance().init(new ImageLoaderConfiguration.Builder(this)
            .threadPriority(Thread.NORM_PRIORITY - 2)
            .denyCacheImageMultipleSizesInMemory()
            .discCacheFileNameGenerator(new Md5FileNameGenerator())
            .tasksProcessingOrder(QueueProcessingType.LIFO)
            .build());
}
 
Example 5
Source File: UserInFragmentActivity.java    From XBanner with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_user_in_fragment);
    RadioGroup rbTab = findViewById(R.id.rg_tab);
    RadioButton radioButton= (RadioButton) rbTab.getChildAt(0);
    radioButton.setChecked(true);
    mFragmentList=new ArrayList<>();
    mFragmentList.add(BannerFragment.newInstance());
    mFragmentList.add(BannerFragment.newInstance());
    mFragmentList.add(BannerFragment.newInstance());
    mFragmentList.add(BannerFragment.newInstance());
    FragmentUtils.add(getSupportFragmentManager(),mFragmentList,R.id.fragment_content,0);
    rbTab.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            switch (checkedId) {
                case R.id.tab_1:
                    FragmentUtils.showHide(0,mFragmentList);
                    break;
                case R.id.tab_2:
                    FragmentUtils.showHide(1,mFragmentList);
                    break;
                case R.id.tab_3:
                    FragmentUtils.showHide(2,mFragmentList);
                    break;
                case R.id.tab_4:
                    FragmentUtils.showHide(3,mFragmentList);
                    break;
                default:
                    break;
            }
        }
    });
}
 
Example 6
Source File: DownloadNumDialog.java    From Aria with Apache License 2.0 5 votes vote down vote up
@Override public void onCheckedChanged(RadioGroup group, int checkedId) {
  RadioButton rb = (RadioButton) group.getChildAt(checkedId);
  if (rb.isChecked()) {
    getSimplerModule().onDialog(RESULT_CODE, rb.getTag());
    dismiss();
  }
}
 
Example 7
Source File: MainActivity.java    From BlogDemo with Apache License 2.0 5 votes vote down vote up
private void init() {
    mFm = getSupportFragmentManager();
    mNavigationBar = (RadioGroup) findViewById(R.id.navigation);

    int size = (int) getResources().getDimension(R.dimen.navigation_top_icon_size);
    for (int i = 0, count = mNavigationBar.getChildCount(); i < count; i++) {
        RadioButton rb = (RadioButton) mNavigationBar.getChildAt(i);
        Drawable topIcon = getResources().getDrawable(R.drawable.selector_navigation_bg);
        topIcon.setBounds(0, 0, size, size);
        rb.setCompoundDrawables(null, topIcon, null, null);
        rb.setId(i);
    }
    mNavigationBar.setOnCheckedChangeListener(this);
    ((RadioButton) mNavigationBar.getChildAt(0)).setChecked(true);
}
 
Example 8
Source File: MainActivity.java    From BlogDemo with Apache License 2.0 5 votes vote down vote up
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
    RadioButton rb = (RadioButton) group.getChildAt(checkedId);
    if (rb.isChecked()) {
        chooseFragment(String.valueOf(rb.getTag()));
    }
}
 
Example 9
Source File: ThemeSwitcherDialogFragment.java    From material-components-android with Apache License 2.0 4 votes vote down vote up
private void initializeThemingValues(
    RadioGroup group,
    @ArrayRes int overlays,
    @ArrayRes int contentDescriptions,
    @StyleableRes int[] themeOverlayAttrs,
    @IdRes int overlayId,
    ThemingType themingType) {
  TypedArray themingValues = getResources().obtainTypedArray(overlays);
  TypedArray contentDescriptionArray = getResources().obtainTypedArray(contentDescriptions);
  if (themingValues.length() != contentDescriptionArray.length()) {
    throw new IllegalArgumentException(
        "Feature array length doesn't match its content description array length.");
  }

  for (int i = 0; i < themingValues.length(); i++) {
    @StyleRes int valueThemeOverlay = themingValues.getResourceId(i, 0);
    ThemeAttributeValues themeAttributeValues = null;
    // Create RadioButtons for themeAttributeValues values
    switch (themingType) {
      case COLOR:
        themeAttributeValues = new ColorPalette(valueThemeOverlay, themeOverlayAttrs);
        break;
      case SHAPE_CORNER_FAMILY:
        themeAttributeValues = new ThemeAttributeValues(valueThemeOverlay);
        break;
      case SHAPE_CORNER_SIZE:
        themeAttributeValues =
            new ThemeAttributeValuesWithContentDescription(
                valueThemeOverlay, contentDescriptionArray.getString(i));
        break;
    }

    // Expect the radio group to have a RadioButton as child for each themeAttributeValues value.
    AppCompatRadioButton button =
        themingType.radioButtonType == RadioButtonType.XML
            ? ((AppCompatRadioButton) group.getChildAt(i))
            : createCompatRadioButton(group, contentDescriptionArray.getString(i));

    button.setTag(themeAttributeValues);
    themeAttributeValues.customizeRadioButton(button);

    int currentThemeOverlay = ThemeOverlayUtils.getThemeOverlay(overlayId);
    if (themeAttributeValues.themeOverlay == currentThemeOverlay) {
      group.check(button.getId());
    }
  }

  themingValues.recycle();
  contentDescriptionArray.recycle();
}
 
Example 10
Source File: CustomDrawableDemo.java    From support with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.custom_drawable_layout);
    final int color = 0xff35b558;
    int strokeWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2f, getResources().getDisplayMetrics());
    int corner = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5f, getResources().getDisplayMetrics());


    SegmentDrawable drawable1 = new SegmentDrawable(SegmentDrawable.Style.LEFT_EDGE);
    drawable1.setStrokeWidth(strokeWidth);
    drawable1.setColor(color);
    drawable1.setCornerRadius(corner);
    findViewById(R.id.label).setBackgroundDrawable(drawable1);

    SegmentDrawable drawable2 = new SegmentDrawable(SegmentDrawable.Style.MIDDLE);
    drawable2.setStrokeWidth(strokeWidth);
    drawable2.setColor(color);
    drawable2.setCornerRadius(corner);

    findViewById(R.id.label2).setBackgroundDrawable(drawable2);

    SegmentDrawable drawable3 = new SegmentDrawable(SegmentDrawable.Style.RIGHT_EDGE);
    drawable3.setStrokeWidth(strokeWidth);
    drawable3.setColor(color);
    drawable3.setCornerRadius(corner);

    findViewById(R.id.label3).setBackgroundDrawable(drawable3);

    RadioGroup group = (RadioGroup) findViewById(R.id.container);
    int count = group.getChildCount();

    for (int i = 0; i < count; i++) {
        RadioButton child = (RadioButton) group.getChildAt(i);

        SegmentDrawable drawable;
        if (i == 0) {
            drawable = new SegmentDrawable(SegmentDrawable.Style.LEFT_EDGE);
            child.setChecked(true);
        } else if (i == count - 1) {
            drawable = new SegmentDrawable(SegmentDrawable.Style.RIGHT_EDGE);
        } else {
            drawable = new SegmentDrawable(SegmentDrawable.Style.MIDDLE);
        }
        drawable.setColor(color);
        drawable.setStrokeWidth(strokeWidth);
        drawable.setCornerRadius(corner);

        child.setButtonDrawable(null);
        child.setBackgroundDrawable(drawable.newStateListDrawable());
    }
}