如何为汽车用品网站创建WordPress社区论坛?

摘要:汽车用品网站,WordPress搭建社区网站,游戏开发工程师是什么专业,潮州网站网站建设目录 一、MVC、MVP和MVVM框架的使用场景二、Java使用 一、MVC、MVP和MVVM框架的使用场景 MVC: 适
汽车用品网站,WordPress搭建社区网站,游戏开发工程师是什么专业,潮州网站网站建设目录 一、MVC、MVP和MVVM框架的使用场景二、Java使用 一、MVC、MVP和MVVM框架的使用场景 MVC#xff1a; 适用于小型项目#xff0c;够灵活#xff0c; 缺点#xff1a;Activity不仅要做View的事情还要做控制和模型的处理#xff0c;导致Activity太过臃肿#xff0c;管理… 目录 一、MVC、MVP和MVVM框架的使用场景二、Java使用 一、MVC、MVP和MVVM框架的使用场景 MVC 适用于小型项目够灵活 缺点Activity不仅要做View的事情还要做控制和模型的处理导致Activity太过臃肿管理混乱没有单一职责耦合度、扩展性都不太好 MVP适用于大型项目、业务很重、项目很大必须分层清楚因为开发的人太好 优点分层特别清晰 缺点出现接口过多、接口地狱问题 MVVM: 适用于界面更新很频繁比如网易云音乐、腾讯视频 DataBinding 是一个工具集不属于哪个框架在MVVM框架中用于完成View层与ViewModel层的双向绑定 大部分情况下MVVM框架都会使用DataBinding小部分情况下MVP框架也可以使用 新的开发模块数据驱动开发DataBinding ViewModel LiveData 特别注意MVVM模式下的ViewModelVM和 Jetpack的ViewModel 不是同一东西MVVM中的ViewModel是层次结构而Jetpack的ViewModel是组件库。 永远没有哪个模式最好只有哪个模式适合你的项目才是最好的 二、Java使用 activity_main.xml布局文件 ?xml version1.0 encodingutf-8? !-- layout是DataBinding管理了 我们整个布局 -- layout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:apphttp://schemas.android.com/apk/res-autoxmlns:toolshttp://schemas.android.com/toolsdata!-- 这里面type写全路径 不是用于反射 --variablenameusertypecom.example.mydatabinding.model.User/variable/data!-- 上面的是DataBinding 内部用的注意Android View体系不认识--!-- Android View体系的 下面的所有内容 会给Android绘制 --LinearLayoutandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:orientationvertical!-- 表示 View - Model 数据传输一向 --EditTextandroid:idid/et1android:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:hintHello World!android:text{user.name}android:textSize50sp/EditTextandroid:idid/et2android:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:hintHello World!android:text{user.pwd}android:textSize50sp//LinearLayout /layout编译之后会生成两个布局文件 在 app/build/intermediates/data_binding_layout_info_type_merge/debug/out/ 目录下生成 activity_main-layout.xml文件 activity_main-layout.xml ?xml version1.0 encodingutf-8 standaloneyes? Layout directorylayout filePathapp\src\main\res\layout\activity_main.xmlisBindingDatatrue isMergefalse layoutactivity_mainmodulePackagecom.example.mydatabinding rootNodeTypeandroid.widget.LinearLayoutVariables nameuser declaredtrue typecom.example.mydatabinding.model.Userlocation endLine10 endOffset18 startLine7 startOffset8 //VariablesTargetsTarget taglayout/activity_main_0 viewLinearLayoutExpressions /location endLine42 endOffset18 startLine18 startOffset4 //TargetTarget idid/et1 tagbinding_1 viewEditTextExpressionsExpression attributeandroid:text textuser.nameLocation endLine29 endOffset39 startLine29 startOffset12 /TwoWaytrue/TwoWayValueLocation endLine29 endOffset37 startLine29 startOffset29 //Expression/Expressionslocation endLine31 endOffset13 startLine24 startOffset8 //TargetTarget idid/et2 tagbinding_2 viewEditTextExpressionsExpression attributeandroid:text textuser.pwdLocation endLine38 endOffset38 startLine38 startOffset12 /TwoWaytrue/TwoWayValueLocation endLine38 endOffset36 startLine38 startOffset29 //Expression/Expressionslocation endLine40 endOffset13 startLine33 startOffset8 //Target/Targets /Layout这个xml文件就相当于activity_main.xml布局文件中的这一截里面的内容 2. 在 app/build/intermediates/incremental/mergeDebugResources/stripped.dir/layout/ 目录下生成 activity_main.xml文件这个xml就相当于原activity_main.xml布局文件中的这一截里面的内容 activity_main.xml ?xml version1.0 encodingutf-8?!-- layout是DataBinding管理了 我们整个布局 --!-- 上面的是DataBinding 内部用的注意Android View体系不认识--!-- Android View体系的 下面的所有内容 会给Android绘制 --LinearLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:apphttp://schemas.android.com/apk/res-autoxmlns:toolshttp://schemas.android.com/toolsandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:orientationverticalandroid:taglayout/activity_main_0!-- 表示 View - Model 数据传输一向 --EditTextandroid:idid/et1android:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:hintHello World!android:tagbinding_1android:textSize50sp /EditTextandroid:idid/et2android:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:hintHello World!android:tagbinding_2android:textSize50sp //LinearLayout