RadioGroupPlus icon indicating copy to clipboard operation
RadioGroupPlus copied to clipboard

not working if added runtime

Open bb1690 opened this issue 9 years ago • 2 comments

I need to add custom views to the radio group it seems working when added on layout. But its not working when added dynamically.

bb1690 avatar Feb 03 '17 11:02 bb1690

Same for me. If I use RadioGroupPlus.addView(...) to add a LinearLayout which contains a RadioButton, only the 1st LinearLayout (together with its radio button) is displayed. So this piece of solution is incomplete.

xuancong84 avatar May 18 '21 05:05 xuancong84

It turns out to be an Android SDK bug in LinearLayout which the RadioGroupPlus class extends. LinearLayout has an attribute called orientation that can be either VERTICAL or HORIZONTAL. By right, it can be set either in XML or source code: In XML:

    <com.moht.hopes.survey.RadioGroupPlus
		android:id="@+id/radioGroupPlus"
		android:orientation="vertical"
		android:layout_width="wrap_content"
		android:layout_height="wrap_content"
		android:paddingLeft="50dp"
		android:paddingRight="50dp"
		android:paddingTop="10dp"
		android:paddingBottom="50dp" />

In source code,

	public RadioGroupPlus(Context context) {
		super(context);
		setOrientation(VERTICAL);
		init();
	}

However, it turns out that this orientation can only be set effectively in XML, if you don't set it in XML, if will default to HORIZONTAL. Later, even if you set it to VERTICAL in the source code, it will still be horizontal and thus, only the 1st item is shown.

xuancong84 avatar May 19 '21 03:05 xuancong84