Code example for RadioButton

Methods: setText, setId, setOnClickListener, setTag

0
	 * @param urlText 
	 */ 
	private void setRadioState(RadioGroup radioGroup, int index,
			boolean isCustom, String titleText, String urlText) {
 
		RadioButton rb = new RadioButton(this);
 
		rb.setId(index);
 
		SpannableStringBuilder result = new SpannableStringBuilder();
 
		SpannableString titleSpan = new SpannableString(titleText);
		titleSpan.setSpan(new TextAppearanceSpan(this,
				android.R.style.TextAppearance_Medium), 0, titleText.length(),
				Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
 
		SpannableString urlSpan = new SpannableString(urlText);
		urlSpan.setSpan(new TextAppearanceSpan(this,
				android.R.style.TextAppearance_Small), 0, urlText.length(),
				Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
 
		result.append(titleSpan);
		result.append(System.getProperty("line.separator"));
		result.append(urlSpan);
 
		rb.setText(result, BufferType.SPANNABLE);
		rb.setTag(urlText);
 
		if (isCustom) {
 
			// keep the edit link always to the right of the row 
			final LinearLayout.LayoutParams rowParams = new LinearLayout.LayoutParams(
					LinearLayout.LayoutParams.FILL_PARENT,
					LinearLayout.LayoutParams.WRAP_CONTENT);
			rowParams.weight = 1;
 
			final LinearLayout.LayoutParams buttonParams = new LinearLayout.LayoutParams(
					LinearLayout.LayoutParams.WRAP_CONTENT,
					LinearLayout.LayoutParams.WRAP_CONTENT);
			buttonParams.weight = (float) 0.75;
 
			final LinearLayout.LayoutParams linkParams = new LinearLayout.LayoutParams(
					LinearLayout.LayoutParams.WRAP_CONTENT,
					LinearLayout.LayoutParams.FILL_PARENT);
			// interesting side effect of this? if the url gets big, the runtime 
			// will shrink this guy, doesn't matter if the w/h are set 
			// linkParams.weight=(float)0.25; 
			linkParams.gravity = Gravity.CENTER_HORIZONTAL
					| Gravity.CENTER_VERTICAL;
 
			ImageView iv = new ImageView(this);
			iv.setImageResource(salesforceR.drawableEditIcon());
			iv.setOnClickListener(new View.OnClickListener() {
				@Override 
				public void onClick(View v) {
					showCustomUrlDialog(null); 
				} 
			}); 
 
			customRadioButtonId = index;
 
			// problem here is that if the radio button is not the top level 
			// child view when adding, 
			// the group does not control it (check the radio group code) so do 
			// it by hand. 
			// **It sort of controls it, you can select it through through the 
			// group but it does not get deselected correctly and is not 
			// returned by a get selected call on the group 
			rb.setOnClickListener(this);
 
			LinearLayout lay = new LinearLayout(this);
			lay.addView(rb, 0, buttonParams);
			lay.addView(iv, 1, linkParams);