Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not working if added runtime #3

Open
bb1690 opened this issue Feb 3, 2017 · 2 comments
Open

not working if added runtime #3

bb1690 opened this issue Feb 3, 2017 · 2 comments

Comments

@bb1690
Copy link

bb1690 commented Feb 3, 2017

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

@xuancong84
Copy link

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
Copy link

xuancong84 commented May 19, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants