使用MVVM或MVP我应该命名模型,视图模型,视图等包,并将适当的类和接口放在那里,还是只是一个在类结构中不可见的逻辑结构?
答案 0 :(得分:4)
If you want to go by the book, the current "correct" way to implement MVVM in Android is the Android Architecture Components set of libraries.
Read more about it here, and try this code lab. These will also show you how to name and place your classes.
But in general, you should go with what matches your app best. For smaller apps I would recommend going with M V P folders, while for bigger, more long-term ones tend to work better with folder-per-feature structure.
答案 1 :(得分:0)
另外,您可能会发现此资源很有趣https://overflow.buffer.com/2016/09/26/android-rethinking-package-structure/ 这里有一个实现https://github.com/SamYStudiO/beaver
答案 2 :(得分:0)
我也想表明您正在观看此TUTORIAL。 这个家伙在架构MVVM 的教学上做得很好,并且还使用了 ROOM 持久性库。 值得一看。
答案 3 :(得分:0)
Google在其示例Android体系结构项目中使用Model(Data)V(views)VM(view-models)文件结构 Google sample sunflower app to show architecture components 也许那是最好的方法