janishar/android-mvvm-architecture

The problem when you have 2 layouts for one Fragment/Activity

f0rev opened this issue · 0 comments

f0rev commented

Hi. There is one problem with associating layouts to e.g. fragment.
Let's say you have MainActivity and two layouts for it (activity_main_normal.xml, activity_main_small.xml). So if u want to choose which layout to inflate from
public int getLayoutId() { if(someCase){ return R.layout.activity_main_small; } else { return R.layout.activity_main_small; }
then you will get:
java.lang.ClassCastException: ActivityMainSmallBindingImpl cannot be cast to ActivityMainBinding

So, how would you resolve that kind of problem?