janishar / android-mvvm-architecture

This repository contains a detailed sample app that implements MVVM architecture using Dagger2, Room, RxJava2, FastAndroidNetworking and PlaceholderView
https://janisharali.com
Apache License 2.0
2.95k stars 936 forks source link

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

Closed f0rev closed 5 years ago

f0rev commented 5 years ago

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?