Dear Andy,
I'd like to implement an activity which contains a viewpager and other controls (eg. displaying the currently displayed view-index by the viewpager).
I followed this article to implement such feature:
Then I wanted to incorporate AndroidBinding's MVVM to both my main-activity and the displayed subviews (as fragments), though I read that you decided not to support AndroidBinding with Fragments, but in this forum I've found some advices you gave to others how to use binding inside fragments.
I would like an opinion from you whether my approach is the way to go to implement such scenario, or whether you recommend another approach (again, the viewpager should not be fullscreen).
- the MainActivity extends FragmentActivity (coming from the
dev.android.com example) - can't change this to any BindingActivity, because the ViewPager setup needs getSupportFragmentManager()
- in the MainActivity's onCreate I can't call the default "setContentView(R.layout.activity_main);" because I want binding, neither can I call 'setAndBindRootView(R.layout.activity_main, new TestVM(this));' because my main Activity is not a BindingActivity, but FragmentActivity
- so I use the following code:
Binder.InflateResult result = Binder.inflateView(this, R.layout.activity_main, null, false);
Binder.bindView(this, result, _pagerVM);
setContentView(result.rootView);
- In my fragments' onCreateView I do this:
Binder.InflateResult result = Binder.inflateView(container.getContext(), R.layout.childview, null, false);
return Binder.bindView(container.getContext(), result, _vm);
Also, another question would be, if in the future I'd need to use BindingABSAcitivity (etc), what are my options? BindingABSActivity is not subclass of FragmentActivity, so.... ?!
I checked the ICSDemo's ViewPager layout demo-screen but something might be wrong here, because the whole behavior is a little awkward, not whole pages are scrolled/paged, but many times the screen displayes pages next to each other separated by a divider, etc...
Thanks a lot for your time and waiting for your your kind answer,
Csabi