getChildAt ( )源码实例Demo

android.widget.RadioGroup#getChildAt ( )源码实例Demo

下面列出了android.widget.RadioGroup#getChildAt ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: AndroidRipper   文件: SimpleNoValuesExtractor.java
/**
 * 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;
}
 
源代码2 项目: AndroidRipper   文件: SimpleExtractor.java
/**
 * 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;
}
 
源代码3 项目: AndroidRipper   文件: ReflectionExtractor.java
/**
 * 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;
}
 
源代码4 项目: ZoomImageView   文件: SimpleImageAct.java
@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());
}
 
源代码5 项目: XBanner   文件: UserInFragmentActivity.java
@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;
            }
        }
    });
}
 
源代码6 项目: Aria   文件: DownloadNumDialog.java
@Override public void onCheckedChanged(RadioGroup group, int checkedId) {
  RadioButton rb = (RadioButton) group.getChildAt(checkedId);
  if (rb.isChecked()) {
    getSimplerModule().onDialog(RESULT_CODE, rb.getTag());
    dismiss();
  }
}
 
源代码7 项目: BlogDemo   文件: MainActivity.java
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);
}
 
源代码8 项目: BlogDemo   文件: MainActivity.java
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
    RadioButton rb = (RadioButton) group.getChildAt(checkedId);
    if (rb.isChecked()) {
        chooseFragment(String.valueOf(rb.getTag()));
    }
}
 
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();
}
 
源代码10 项目: support   文件: CustomDrawableDemo.java
@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());
    }
}