1

We have created a table dynamically in our main activity, however we need to make the table scrollable. In XMLs I would just put the table layout inside a Scroll layout. Is there a way to do this dynamically through the activity?

1 Answer 1

1

Sure, you can put your entire layout inside of a ScrollView programmatically like this:

 LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.mylayout, null);
ScrollView scrollView = new ScrollView(this);
scrollView.addView(view);
setContentView(scrollView);
Sign up to request clarification or add additional context in comments.

1 Comment

That works great. We were very close to getting it but needed the addView method. Thanks!

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.