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
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);
1 Comment
Travis Elliott
That works great. We were very close to getting it but needed the addView method. Thanks!