0

I have a ScrollView containing a number of buttons and textviews.

I wish to insert a new button midway (index 3)on the scroll view but get the error, "ScrollView can host only one direct child"

Is this not possible?

Button b = new Button(this);
scrView.AddView(b,3);

????

2 Answers 2

5

Put the sub-views in a layout like LinearLayout or RelativeLayout then put the layout in the ScrollView. Add your views to the layout rather than the ScrollView.

Sign up to request clarification or add additional context in comments.

Comments

0

No you can't add more then one view in scollview as you know now "ScrollView can host only one direct child"

you would definalty have a linear layout in scollview where you would have added other buttons previously so add new one in that......

1 Comment

how about to remove the child of the scrollview first... and then add the new component into it. :D which means, the scrollview still has only ONE single view. right ? @DheereshSingh

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.