# MVVMLight **Repository Path**: wimhu/MVVMLight ## Basic Information - **Project Name**: MVVMLight - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-04-08 - **Last Updated**: 2024-11-24 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # MVVM Light Toolkit --- [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Android--MVVMLight-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/3737) A toolkit help to build Android MVVM Application,We have more attributes for Data Binding of View(like Uri for ImageView) ,we create some command for deal with event( like click of Button),also have a global message pipe to communicate with other ViewModel. ##Download## ```groovy compile 'com.kelin.mvvmlight:library:1.0.0' ``` requires at least android gradle plugin 1.5.0. ##Usage## --- ####中文文档:[MVVM Light Toolkit使用指南](http://www.jianshu.com/p/43ea7a531700)#### ####引申阅读:[如何构建Android MVVM应用程序](http://www.jianshu.com/p/2fc41a310f79)#### ###Data Binding### Binding URI to the ImageView with bind:uri will make it loading bitmap from URI and render to ImageView automatically. ```xml ``` Fresco.initialize(this) is require,because of loading image use Fresco default). ```java public class MyApp extends Application { @Override public void onCreate() { super.onCreate(); Fresco.initialize(this); } ``` --- **Example** ![image.gif](http://upload-images.jianshu.io/upload_images/966283-2e13447dfd5028a1.gif?imageMogr2/auto-orient/strip) --- AdapterView like ListView、RecyclerView 、ViewPager is convenient, bind it to the collection view with app:items and app:itemView,You should use an ObservableList to automatically update your view based on list changes. ```xml itemViewModel = new ObservableArrayList<>(); public final ItemView itemView = ItemView.of(BR.viewModel, R.layout.layoutitem_list_view); ``` Adapter,ViewHolder ..is Not Required: --- **Example** ![listview_databinding.gif](http://upload-images.jianshu.io/upload_images/966283-fb4ae1cdc79ff478.gif?imageMogr2/auto-orient/strip) --- **Other attributes supported:** - *ImageView* ```xml ``` - *ListView*、*ViewPager*、*RecyclerView* ```xml ``` - *ViewGroup* ```xml ``` - *EditText* ```xml ``` - *SimpleDraweeView* ```xml ``` - *WebView* ```xml ``` ###Command Binding### --- When RecyclerView scroll to end of list,we have onLoadMoreCommand to deal with event. ```xml ``` In ViewModel define a ReplyCommand field to deal with this event. ```java public final ReplyCommand loadMoreCommand = new ReplyCommand<>( (count) -> { /*count: count of list items*/ int page=count / LIMIT +1; loadData(page) }); ``` --- **Example** ![listview load more](http://upload-images.jianshu.io/upload_images/966283-4774960c95b4e1e5.gif?imageMogr2/auto-orient/strip) --- Deal with click event of View is more convenient: ```xml