getChildCount ( )源码实例Demo

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

下面列出了android.widget.RadioGroup#getChildCount ( ) 实例代码,或者点击链接到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 项目: Car-Pooling   文件: SearchActivity.java
/**
 * This method is used to select ride that are available to specific destination in the form of radio buttons
 */
private void displayConfirmation(){

    RadioGroup radioGroup= (RadioGroup) findViewById(R.id.RadioButtonGroup);
    if(radioGroup.getChildCount()>0) {
        RadioButton radioButton = (RadioButton) findViewById(radioGroup.getCheckedRadioButtonId());
        String selectedtext = radioButton.getText().toString();
        Toast.makeText(SearchActivity.this, selectedtext, Toast.LENGTH_SHORT).show();

        //Toast.makeText(SearchActivity.this, text[5], Toast.LENGTH_SHORT).show();
        Intent myIntent = new Intent(this, RideConfirmation.class);
        myIntent.putExtra("RideDetails",selectedtext);
        myIntent.putExtra("PickupLocation",address);
        startActivityForResult(myIntent, 0);
        finish();

    }
    else
    {
        Toast.makeText(SearchActivity.this, "No Rides available to book.. Please try again", Toast.LENGTH_SHORT).show();
    }

}
 
源代码5 项目: CoordinatorLayoutExample   文件: ZhiHuAdapter.java
@Override
public void onCheckedChanged(RadioGroup radioGroup, int checkId) {
    for (int i = 0; i < radioGroup.getChildCount(); i++) {
        if (radioGroup.getChildAt(i).getId() == checkId) {
            //  即将要展示的Fragment
            Fragment target = mFragmentList.get(i);
            Fragment currentFragment = getCurrentFragment();
            currentFragment.onPause();

            FragmentTransaction fragmentTransaction = getFragmentTransaction();
            if (target.isAdded()) {
                target.onResume();
                fragmentTransaction.show(target).hide(currentFragment);

            } else {
                fragmentTransaction.add(mContentId, target).show(target).hide(currentFragment);
            }
            fragmentTransaction.commit();
            currentTab = i;

            if (mFragmentToogleListener != null) {
                mFragmentToogleListener.onToogleChange(target, currentTab);
            }

        }
    }

}
 
源代码6 项目: edx-app-android   文件: MainDiscoveryFragment.java
private void setTabsBackground(@NonNull RadioGroup options) {
    final int childCount = options.getChildCount();
    for (int i = 0; i < childCount; i++) {
        if (i == 0) {
            options.getChildAt(i).setBackgroundResource(R.drawable.edx_segmented_control_left_background);
        } else if (i == childCount - 1) {
            options.getChildAt(i).setBackgroundResource(R.drawable.edx_segmented_control_right_background);
        } else {
            options.getChildAt(i).setBackgroundResource(R.drawable.edx_segmented_control_middle_background);
        }
    }
}
 
源代码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 项目: 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());
    }
}
 
源代码9 项目: smartcard-reader   文件: AppViewActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_app_view);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });

    // persistent data in shared prefs
    SharedPreferences ss = getSharedPreferences("prefs", Context.MODE_PRIVATE);
    mEditor = ss.edit();

    mSelectedAppPos = ss.getInt("selected_app_pos", 0);

    Gson gson = new Gson();
    String json = ss.getString("groups", null);
    if (json == null) {
        mUserGroups = new LinkedHashSet<>();
    } else {
        Type collectionType = new TypeToken<LinkedHashSet<String>>() {
        }.getType();
        mUserGroups = gson.fromJson(json, collectionType);
    }

    // alphabetize, case insensitive
    mSortedAllGroups = new ArrayList<>(mUserGroups);
    mSortedAllGroups.addAll(Arrays.asList(DEFAULT_GROUPS));
    Collections.sort(mSortedAllGroups, String.CASE_INSENSITIVE_ORDER);

    // when deleting an app results in an empty group, we remove the group;
    // we may need to adjust group position indices for batch select and app
    // browse activities, which apply to the sorted list of groups
    mSelectedGrpPos = ss.getInt("selected_grp_pos", 0);
    mSelectedGrpName = mSortedAllGroups.get(mSelectedGrpPos);
    mExpandedGrpPos = ss.getInt("expanded_grp_pos", -1);
    mExpandedGrpName = (mExpandedGrpPos == -1) ? "" : mSortedAllGroups.get(mExpandedGrpPos);

    Intent intent = getIntent();
    mAppPos = intent.getIntExtra(EXTRA_APP_POS, 0);

    mName = (EditText) findViewById(R.id.app_name);
    mAid = (EditText) findViewById(R.id.app_aid);
    mType = (RadioGroup) findViewById(R.id.radio_grp_type);
    mNote = (TextView) findViewById(R.id.note);
    mGroups = (TextView) findViewById(R.id.group_list);

    // view only
    mName.setFocusable(false);
    mAid.setFocusable(false);
    for (int i = 0; i < mType.getChildCount(); i++) {
        mType.getChildAt(i).setClickable(false);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window w = getWindow();
        w.setFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS,
                WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS |
                        WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        w.setStatusBarColor(getResources().getColor(R.color.primary_dark));
    }
}
 
源代码10 项目: APDE   文件: SketchPropertiesFragment.java
public void rebuildIconChange() {
	//Original image
	final ImageView bigIcon = changeIconLayout.findViewById(R.id.big_icon);
	//Image after cropping and scaling
	final ImageView smallIcon = changeIconLayout.findViewById(R.id.small_icon);
	
	//Alt text for the big icon
	final TextView bigIconAltText = changeIconLayout.findViewById(R.id.big_icon_alt_text);
	
	//Scale format radio group
	final RadioGroup scaleFormat = changeIconLayout.findViewById(R.id.format_scale);
	
	Bitmap bitmap = loadBitmap();
	
	if (bitmap != null) {
		int w = bitmap.getWidth();
		int h = bitmap.getHeight();
		
		int dim = changeIconLayout.getWidth();
		
		if (w > dim || h > dim) {
			//Resize the bitmap to fit the dialog
			
			if (Math.min(w, h) == w) {
				int scaleW = Math.round(w / (((float) h) / dim));
				
				bigIcon.setImageBitmap(Bitmap.createScaledBitmap(bitmap, scaleW, dim, false));
			} else {
				int scaleH = Math.round(h / (((float) w) / dim));
				
				bigIcon.setImageBitmap(Bitmap.createScaledBitmap(bitmap, dim, scaleH, false));
			}
		} else {
			bigIcon.setImageBitmap(bitmap);
		}
		
		int iconSize = Math.round(36 * getResources().getDisplayMetrics().density);
		
		smallIcon.setImageBitmap(formatIcon(bitmap, iconSize, getScaleFormat(scaleFormat)));
		
		bigIcon.setVisibility(View.VISIBLE);
		bigIconAltText.setVisibility(View.GONE);
		
		changeIconOK.setEnabled(true);
		for (int i = 0; i < scaleFormat.getChildCount(); i++) {
			((RadioButton) scaleFormat.getChildAt(i)).setEnabled(true);
		}
		
		return;
	}
	
	//If we were unable to load the image...
	
	bigIcon.setImageBitmap(null);
	
	//Load the old icon for the current sketch
	
	File sketchFolder = getGlobalState().getSketchLocation();
	String[] iconTitles = com.calsignlabs.apde.build.Build.ICON_LIST;
	
	String iconPath = "";
	
	for (String iconTitle : iconTitles) {
		File icon = new File(sketchFolder, iconTitle);
		
		if (icon.exists()) {
			iconPath = icon.getAbsolutePath();
			break;
		}
	}
	
	if (!iconPath.equals("")) {
		Bitmap oldIcon = BitmapFactory.decodeFile(iconPath);
		
		if (oldIcon != null) {
			smallIcon.setImageBitmap(oldIcon);
		} else {
			//Uh-oh, some error occurred...
		}
	} else {
		smallIcon.setImageDrawable(getResources().getDrawable(R.drawable.default_icon));
	}
	
	bigIcon.setVisibility(View.GONE);
	bigIconAltText.setVisibility(View.VISIBLE);
	
	changeIconOK.setEnabled(false);
	for (int i = 0; i < scaleFormat.getChildCount(); i ++) {
		((RadioButton) scaleFormat.getChildAt(i)).setEnabled(false);
	}
}