{"id":319999,"date":"2021-03-22T03:00:06","date_gmt":"2021-03-22T03:00:06","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=319999"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=319999","title":{"rendered":"\u041b\u0435\u0433\u043a\u0438\u0439 DataBinding \u0434\u043b\u044f Android"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/669\/9f5\/a05\/6699f5a05582ecc710197463874772c6.png\" width=\"1070\" height=\"400\"><figcaption><\/figcaption><\/figure>\n<p>\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435 \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u044b\u0435 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0438. \u0412\u0441\u0435 \u043c\u044b \u043b\u044e\u0431\u0438\u043c \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <a href=\"https:\/\/developer.android.com\/topic\/libraries\/data-binding\" rel=\"noopener noreferrer nofollow\">DataBinding<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043b\u0430 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u044f Google \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043b\u0435\u0442 \u043d\u0430\u0437\u0430\u0434, \u0434\u043b\u044f \u0441\u0432\u044f\u0437\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0432\u044c\u044e\u0448\u043a\u0430\u043c\u0438 \u0447\u0435\u0440\u0435\u0437 ViewModel. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435, \u0445\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0432\u0430\u043c\u0438, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0443\u043d\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044f\u0437\u044b\u043a\u0430 Kotlin, \u0438 \u0443\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u043e\u0432 \u0434\u043b\u044f RecyclerView (\u0434\u0430\u043b\u0435\u0435 RV), ViewPager \u0438 ViewPager2 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u043e\u0447\u0435\u043a \u043a\u043e\u0434\u0430. <\/p>\n<p>\u041d\u0430\u0447\u043d\u0443 \u0441 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0440\u0430\u043d\u044c\u0448\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043b\u0438 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0435 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b\u0438 ViewHolder&#8217;\u044b, \u0438 \u0438\u0445 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435, \u0430 \u0442\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430, \u0437\u0430\u043d\u0438\u043c\u0430\u043b\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0438\u043f\u0438\u0447\u043d\u043e\u0433\u043e \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430 \u0434\u043b\u044f RV:<\/p>\n<pre><code class=\"kotlin\">class CustomAdapter(private val dataSet: Array&lt;String&gt;) : RecyclerView.Adapter&lt;CustomAdapter.ViewHolder&gt;() {&nbsp; &nbsp;       &nbsp; &nbsp; class ViewHolder(view: View) : RecyclerView.ViewHolder(view) { &nbsp; &nbsp; &nbsp; &nbsp; val textView: TextView&nbsp; &nbsp; &nbsp; &nbsp;          init { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; textView = view.findViewById(R.id.textView) &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; }&nbsp; &nbsp;      &nbsp; &nbsp; override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): ViewHolder { &nbsp; &nbsp; &nbsp; &nbsp; val view = LayoutInflater.from(viewGroup.context).inflate(R.layout.text_row_item, viewGroup, false)&nbsp; &nbsp; &nbsp; &nbsp;        return ViewHolder(view) &nbsp; &nbsp; }&nbsp; &nbsp;        &nbsp; &nbsp; override fun onBindViewHolder(viewHolder: ViewHolder, position: Int) {&nbsp; &nbsp; &nbsp; &nbsp; \/\/ Get element from your dataset at this position and replace the &nbsp; &nbsp; &nbsp; &nbsp; viewHolder.textView.text = dataSet[position] &nbsp; &nbsp; }&nbsp; &nbsp;       &nbsp; &nbsp; override fun getItemCount() = dataSet.size }<\/code><\/pre>\n<p>\u0421 \u0442\u0435\u043c \u043a\u0430\u043a \u043f\u0440\u043e\u0435\u043a\u0442 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435. \u041f\u043e\u043c\u043d\u044e, \u043e\u0434\u043d\u0430\u0436\u0434\u044b, \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u0431\u044b\u043b \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0433\u0440\u043e\u043c\u043d\u044b\u0439, \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0442\u0435\u043d \u0441\u0442\u0440\u043e\u0447\u0435\u043a \u043a\u043e\u0434\u0430, \u0447\u0442\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0442\u0430\u043c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u0430 \u0442\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u043d\u043e\u0432\u043e\u0435 \u0437\u0430\u043d\u0438\u043c\u0430\u043b\u043e \u043a\u043e\u043b\u043e\u0441\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u043c\u043e\u0434\u0435\u043b\u044f\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u0442\u0430\u043a \u0436\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u043b \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 <em>\u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f<\/em> \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445. \u0427\u0435\u0441\u0442\u043d\u043e \u0441\u043a\u0430\u0436\u0443, \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u0442\u044f\u0436\u0435\u043b\u043e.<\/p>\n<p>\u0417\u0430\u0442\u0435\u043c \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f <a href=\"https:\/\/developer.android.com\/topic\/libraries\/data-binding\" rel=\"noopener noreferrer nofollow\"><strong>DataBinding<\/strong><\/a> \u0438 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u043f\u043e \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u044e \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u043b\u0430\u0441\u044c \u043d\u0430 \u043d\u0435\u0433\u043e, \u043d\u043e \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u044b \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u0432\u0440\u0443\u0447\u043d\u0443\u044e, \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0438\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0442\u043e\u0434\u044b <code>onCreateViewHolder<\/code>, \u0433\u0434\u0435 \u0432\u043c\u0435\u0441\u0442\u043e \u0438\u043d\u0444\u043b\u044d\u0439\u0442\u0438\u043d\u0433\u0430 \u0447\u0435\u0440\u0435\u0437 <code>LayoutInflater<\/code>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f <code>DataBindingUtil.inflate<\/code>, \u0430 \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 <em>\u0432\u044c\u044e\u0445\u043e\u043b\u0434\u0435\u0440\u043e\u0432<\/em> \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043b\u0438\u0441\u044c \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441 \u0441\u0430\u043c\u043e\u0439 \u0432\u044c\u044e\u0448\u043a\u043e\u0439 \u0447\u0435\u0440\u0435\u0437 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0431\u0430\u0439\u0434\u0438\u043d\u0433\u0430.<\/p>\n<pre><code class=\"kotlin\">class BindingViewHolder(val binding: ItemTextRowBinding) : RecyclerView.ViewHolder(binding.root)  override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BindingViewHolder {         val binding = DataBindingUtil.inflate&lt;ItemTextRowBinding&gt;(LayoutInflater.from(parent.context), viewType, parent, false)         val viewHolder = BindingViewHolder(binding)         return viewHolder }  override fun onBindViewHolder(holder: BindingViewHolder, position: Int) {       holder.binding.setVariable(BR.item, dataSet[position]) }<\/code><\/pre>\n<p>\u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0443\u0436\u0435 \u043b\u0443\u0447\u0448\u0435, \u043d\u043e \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0432 RV, \u043f\u043e \u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c\u0441\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043b\u0430\u0439\u0430\u0443\u0442\u0430 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u0442\u043e \u0442\u0430\u043a\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0435 \u0441\u0438\u043b\u044c\u043d\u043e \u043f\u043e\u043c\u043e\u0433\u043b\u0430 \u0440\u0435\u0448\u0438\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u043e\u0432. \u0418 \u0437\u0434\u0435\u0441\u044c \u043d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f <a href=\"https:\/\/developer.android.com\/reference\/android\/databinding\/BindingAdapter\" rel=\"noopener noreferrer nofollow\"><strong>BindingAdapter<\/strong><\/a> \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <em>androidx.databinding. <\/em>\u0421 \u0435\u0435 \u043f\u043e\u043c\u043e\u0449\u044c\u044e, \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430 \u0434\u043b\u044f RV, \u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442-\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0442\u043e\u0440 <code>DataBindingRecyclerViewConfig<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0440\u044f\u0434 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0434\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430.<\/p>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043d\u0430 \u0441\u0432\u0435\u0442 \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <a href=\"https:\/\/github.com\/Rasalexman\/easy-recycler-binding\" rel=\"noopener noreferrer nofollow\">EasyRecyclerBinding<\/a>. \u0412 \u043d\u0435\u0435 \u0442\u0430\u043a \u0436\u0435 \u0432\u043e\u0448\u043b\u0438 <a href=\"https:\/\/developer.android.com\/reference\/android\/databinding\/BindingAdapter\" rel=\"noopener noreferrer nofollow\"><strong>BindingAdapters<\/strong><\/a> \u0434\u043b\u044f <em>ViewPager<\/em> \u0438 <em>ViewPager2<\/em>. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<br \/>1) \u0412 \u043b\u0430\u0439\u0430\u0443\u0442\u0435 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e, \u0443\u043a\u0430\u0437\u0430\u0432 \u0438\u0445 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c\u0438 \u0434\u043b\u044f RV, &#8212; <code>app:items<\/code> \u0438 <code>app:rv_config<\/code>.  <\/p>\n<pre><code class=\"xml\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt; &lt;layout xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"     xmlns:app=\"http:\/\/schemas.android.com\/apk\/res-auto\"     xmlns:tools=\"http:\/\/schemas.android.com\/tools\"&gt;      &lt;data&gt;     \t&lt;variable         \tname=\"vm\"         \ttype=\"com.rasalexman.erb.ui.base.ExampleViewModel\" \/&gt;          &lt;variable             name=\"rvConfig\"             type=\"com.rasalexman.easyrecyclerbinding.DataBindingRecyclerViewConfig\" \/&gt;     &lt;\/data&gt;      &lt;androidx.constraintlayout.widget.ConstraintLayout         android:id=\"@+id\/main\"         android:layout_width=\"match_parent\"         android:layout_height=\"match_parent\"&gt;          &lt;androidx.recyclerview.widget.RecyclerView             android:layout_width=\"0dp\"             android:layout_height=\"0dp\"             app:items=\"@{vm.items}\"             app:rv_config=\"@{rvConfig}\"             app:layout_constraintBottom_toBottomOf=\"parent\"             app:layout_constraintEnd_toEndOf=\"parent\"             app:layout_constraintStart_toStartOf=\"parent\"             app:layout_constraintTop_toTopOf=\"parent\"             tools:listitem=\"@layout\/item_recycler\"\/&gt;      &lt;\/androidx.constraintlayout.widget.ConstraintLayout&gt; &lt;\/layout&gt;<\/code><\/pre>\n<p>ViewModel, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c\u0441\u044f \u0432 RV, \u0430 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e DataBindingRecyclerViewConfig.<\/p>\n<pre><code class=\"kotlin\">\/\/ \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u044b \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u043f\u0440\u0438\u043c\u0435\u0440\u0430 class ExampleViewModel : ViewModel() {      val items: MutableLiveData&lt;MutableList&lt;RecyclerItemUI&gt;&gt; = MutableLiveData() }  data class RecyclerItemUI(     val id: String,     val title: String )<\/code><\/pre>\n<p>\u0421\u0430\u043c \u043b\u0430\u0439\u0430\u0443\u0442 \u0434\u043b\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0441\u043f\u0438\u0441\u043a\u0430, \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u0430\u043d\u043d\u044b\u0445, \u0447\u0442\u043e\u0431\u044b \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u0438\u0445 \u0432\u043c\u0435\u0441\u0442\u0435.<\/p>\n<pre><code class=\"xml\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt; &lt;layout xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"     xmlns:app=\"http:\/\/schemas.android.com\/apk\/res-auto\"     xmlns:tools=\"http:\/\/schemas.android.com\/tools\"&gt;      &lt;data&gt;          &lt;variable             name=\"item\"             type=\"com.rasalexman.erb.models.RecyclerItemUI\" \/&gt;     &lt;\/data&gt;      &lt;androidx.constraintlayout.widget.ConstraintLayout         android:layout_width=\"match_parent\"         android:layout_height=\"wrap_content\"         android:background=\"@android:drawable\/list_selector_background\"&gt;          &lt;TextView             android:id=\"@+id\/titleTV\"             android:layout_width=\"match_parent\"             android:layout_height=\"wrap_content\"             android:paddingStart=\"16dp\"             android:paddingTop=\"8dp\"             android:paddingEnd=\"16dp\"             android:textColor=\"@color\/black\"             android:textSize=\"18sp\"             android:text=\"@{item.title}\"             app:layout_constraintEnd_toEndOf=\"parent\"             app:layout_constraintStart_toStartOf=\"parent\"             app:layout_constraintTop_toTopOf=\"parent\"             tools:text=\"Hello world\" \/&gt;          &lt;TextView             android:layout_width=\"match_parent\"             android:layout_height=\"wrap_content\"             android:paddingStart=\"16dp\"             android:paddingEnd=\"16dp\"             android:paddingBottom=\"8dp\"             android:textColor=\"@color\/gray\"             android:textSize=\"14sp\"             android:text=\"@{item.id}\"             app:layout_constraintEnd_toEndOf=\"parent\"             app:layout_constraintStart_toStartOf=\"parent\"             app:layout_constraintTop_toBottomOf=\"@+id\/titleTV\"             tools:text=\"Hello world\" \/&gt;      &lt;\/androidx.constraintlayout.widget.ConstraintLayout&gt; &lt;\/layout&gt;<\/code><\/pre>\n<p>2) \u0412\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0435\u0451 \u0432  \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 \u0438\u043d\u0441\u0442\u0430\u043d\u0441 <em>dataBinding<\/em>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e-\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 <code>createRecyclerConfig&lt;I : Any, BT : ViewDataBinding&gt;<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u0438 \u0432\u0435\u0440\u043d\u0435\u0442  \u0438\u043d\u0441\u0442\u0430\u043d\u0441 <em>DataBindingRecyclerViewConfig<\/em>, \u0443\u043a\u0430\u0437\u0430\u0432 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c id \u043b\u0430\u0439\u0430\u0443\u0442\u0430 \u0434\u043b\u044f \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438, \u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u0430 \u0434\u0430\u043d\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c.<\/p>\n<pre><code class=\"kotlin\">class RecyclerViewExampleFragment : BaseBindingFragment&lt;RvExampleFragmentBinding, ExampleViewModel&gt;() {       override val layoutId: Int get() = R.layout.rv_example_fragment   override val viewModel: ExampleViewModel by viewModels()          override fun initBinding(binding: RvExampleFragmentBinding) {         super.initBinding(binding)         binding.rvConfig = createRecyclerConfig&lt;RecyclerItemUI, ItemRecyclerBinding&gt; {             layoutId = R.layout.item_recycler         \t\titemId = BR.item                     }     } }<\/code><\/pre>\n<p>\u042d\u0442\u043e \u0432\u0441\u0435, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 ViewModel \u0441 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u0441\u043f\u0438\u0441\u043a\u0430 \u0432 RV. \u0422\u0430\u043a \u0436\u0435 \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0437\u043d\u0430\u0447\u0438\u0442\u044c \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0434\u043b\u044f \u0431\u0430\u0439\u0434\u0438\u043d\u0433\u0430 <em>\u0432\u044c\u044e\u0445\u043e\u043b\u0434\u0435\u0440\u0430<\/em>, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a <code>onItemClick,&nbsp;onItemCreate, onItemBind<\/code> &nbsp;\u0438 \u0434\u0440\u0443\u0433\u0438\u0435. <\/p>\n<p>\u0410 \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <em>\u0432\u044c\u044e\u0445\u043e\u043b\u0434\u0435\u0440\u044b<\/em> \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043b\u0430\u0439\u0430\u0443\u0442\u0430\u043c\u0438, \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u044b \u0441\u0432\u043e\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u043d\u0438\u0445 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <a href=\"https:\/\/github.com\/Rasalexman\/easy-recycler-binding\" rel=\"noopener noreferrer nofollow\">EasyRecyclerBinding<\/a> &#8212; <code>IBindingModel<\/code>&nbsp;\u0438 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u043e\u043b\u0435 <code>layoutResId<\/code>,  &#8212; id \u043b\u0430\u0439\u0430\u0443\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435. <\/p>\n<pre><code class=\"kotlin\">data class RecyclerItemUI(     \t\tval id: String,     val title: String ) : IBindingModel {         override val layoutResId: Int             \t\tget() = R.layout.item_recycler } data class RecyclerItemUI2(     val id: String,     val title: String ) : IBindingModel {     override val layoutResId: Int         get() = R.layout.item_recycler2 }<\/code><\/pre>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u043b\u044f \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 <em>\u0432\u044c\u044e\u0445\u043e\u043b\u0434\u0435\u0440\u0430\u043c\u0438<\/em> \u043d\u0435 \u0441\u0438\u043b\u044c\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0432\u044b\u0448\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0439, \u043a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u0440\u0443\u0433\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f-\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 <code>createRecyclerMultiConfig<\/code> \u0434\u043b\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0443\u0436\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0442\u0438\u043f \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0431\u0430\u0439\u0434\u0438\u043d\u0433\u0430.<\/p>\n<pre><code class=\"kotlin\">class RecyclerViewExampleFragment : BaseBindingFragment&lt;RvExampleFragmentBinding, RecyclerViewExampleViewModel&gt;() {       override val layoutId: Int get() = R.layout.rv_example_fragment     override val viewModel: RecyclerViewExampleViewModel by viewModels()          override fun initBinding(binding: RvExampleFragmentBinding) {         super.initBinding(binding)         binding.rvConfig = createRecyclerMultiConfig {             itemId = BR.item         }     } }  class RecyclerViewExampleViewModel : BasePagesViewModel() {     open val items: MutableLiveData&lt;MutableList&lt;IBindingModel&gt;&gt; = MutableLiveData() }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u043e\u0432 \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 RV, \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b\u043e\u0441\u044c \u0432 \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0443\u044e \u0438\u0437 \u043f\u0430\u0440\u044b \u0441\u0442\u0440\u043e\u0447\u0435\u043a \u043a\u043e\u0434\u0430, \u0433\u0434\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443 \u0443\u0436\u0435 \u043d\u0435 \u043d\u0430\u0434\u043e \u0434\u0443\u043c\u0430\u0442\u044c \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c, \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u043d\u0435 \u043d\u0443\u0436\u043d\u0443\u044e \u0447\u0430\u0441\u0442\u044c <em>presentation<\/em> \u0441\u043b\u043e\u044f. \u0418 \u0434\u0430\u0436\u0435, \u0435\u0441\u043b\u0438 \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0451 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0438 \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u0435\u0433\u043e \u0441 \u043d\u043e\u0432\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u043d\u0435 \u0437\u0430\u0431\u043e\u0442\u044f\u0441\u044c \u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0435 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u043e\u0432.<\/p>\n<p>\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u043e\u0432 \u0434\u043b\u044f ViewPager \u0438 ViewPager2, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0430 github \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u043a\u043e\u0434\u043e\u043c, \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u044f \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u043b \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438. \u0412 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0435\u0449\u0435 \u0434\u043e\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0438 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0430\u0434\u0435\u043a\u0432\u0430\u0442\u043d\u044b\u0439 \u0444\u0438\u0434\u0431\u0435\u043a, \u0438 \u043f\u043e\u0436\u0435\u043b\u0430\u043d\u0438\u044f \u043f\u043e \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c\u0443 \u0435\u0435 \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u044e. \u0422\u0430\u043a \u0436\u0435 \u0432 \u043d\u0435\u0451 \u0432\u043e\u0448\u043b\u0438 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u043d\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0431\u0430\u0439\u0434\u0438\u043d\u0433\u0430, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0432 \u0441\u0432\u044f\u0437\u043a\u0435 \u0441 ViewModel. (LayoutInflater.createBinding, Fragment.createBindingWithViewModel, etc)<\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e, \u0447\u0442\u043e \u0434\u043e\u0447\u0438\u0442\u0430\u043b\u0438 \u0434\u043e \u043a\u043e\u043d\u0446\u0430. \u041f\u0440\u0438\u044f\u0442\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0438\u043d\u0433\u0430 \u0438 \u0445\u043e\u0440\u043e\u0448\u0435\u0433\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f)<\/p>\n<div class=\"embed_link\">\n<div class=\"embed__thumb\" style=\"background-image: url(&quot;https:\/\/avatars.githubusercontent.com\/u\/1862644?s=400&amp;v=4&quot;);\"><\/div>\n<div class=\"embed__caption\">\n<div class=\"embed__caption-title\"><span>Rasalexman\/easy-recycler-binding<\/span><\/div>\n<p><a href=\"https:\/\/github.com\/Rasalexman\/easy-recycler-binding\" target=\"_blank\" rel=\"noopener noreferrer nofollow\" class=\"embed__caption-link\">github.com<\/a><\/div>\n<\/div>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/548218\/\"> https:\/\/habr.com\/ru\/post\/548218\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435 \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u044b\u0435 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0438. \u0412\u0441\u0435 \u043c\u044b \u043b\u044e\u0431\u0438\u043c \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <a href=\"https:\/\/developer.android.com\/topic\/libraries\/data-binding\" rel=\"noopener noreferrer nofollow\">DataBinding<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043b\u0430 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u044f Google \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043b\u0435\u0442 \u043d\u0430\u0437\u0430\u0434, \u0434\u043b\u044f \u0441\u0432\u044f\u0437\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0432\u044c\u044e\u0448\u043a\u0430\u043c\u0438 \u0447\u0435\u0440\u0435\u0437 ViewModel. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435, \u0445\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0432\u0430\u043c\u0438, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0443\u043d\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044f\u0437\u044b\u043a\u0430 Kotlin, \u0438 \u0443\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u043e\u0432 \u0434\u043b\u044f RecyclerView (\u0434\u0430\u043b\u0435\u0435 RV), ViewPager \u0438 ViewPager2 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u043e\u0447\u0435\u043a \u043a\u043e\u0434\u0430. <\/p>\n<p>\u041d\u0430\u0447\u043d\u0443 \u0441 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0440\u0430\u043d\u044c\u0448\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043b\u0438 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0435 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b\u0438 ViewHolder&#8217;\u044b, \u0438 \u0438\u0445 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435, \u0430 \u0442\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430, \u0437\u0430\u043d\u0438\u043c\u0430\u043b\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0438\u043f\u0438\u0447\u043d\u043e\u0433\u043e \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430 \u0434\u043b\u044f RV:<\/p>\n<pre><code class=\"kotlin\">class CustomAdapter(private val dataSet: Array&lt;String&gt;) : RecyclerView.Adapter&lt;CustomAdapter.ViewHolder&gt;() {&nbsp; &nbsp;       &nbsp; &nbsp; class ViewHolder(view: View) : RecyclerView.ViewHolder(view) { &nbsp; &nbsp; &nbsp; &nbsp; val textView: TextView&nbsp; &nbsp; &nbsp; &nbsp;          init { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; textView = view.findViewById(R.id.textView) &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; }&nbsp; &nbsp;      &nbsp; &nbsp; override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): ViewHolder { &nbsp; &nbsp; &nbsp; &nbsp; val view = LayoutInflater.from(viewGroup.context).inflate(R.layout.text_row_item, viewGroup, false)&nbsp; &nbsp; &nbsp; &nbsp;        return ViewHolder(view) &nbsp; &nbsp; }&nbsp; &nbsp;        &nbsp; &nbsp; override fun onBindViewHolder(viewHolder: ViewHolder, position: Int) {&nbsp; &nbsp; &nbsp; &nbsp; \/\/ Get element from your dataset at this position and replace the &nbsp; &nbsp; &nbsp; &nbsp; viewHolder.textView.text = dataSet[position] &nbsp; &nbsp; }&nbsp; &nbsp;       &nbsp; &nbsp; override fun getItemCount() = dataSet.size }<\/code><\/pre>\n<p>\u0421 \u0442\u0435\u043c \u043a\u0430\u043a \u043f\u0440\u043e\u0435\u043a\u0442 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435. \u041f\u043e\u043c\u043d\u044e, \u043e\u0434\u043d\u0430\u0436\u0434\u044b, \u0430\u0434\u0430\u043f\u0442\u0435\u0440 \u0431\u044b\u043b \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0433\u0440\u043e\u043c\u043d\u044b\u0439, \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0442\u0435\u043d \u0441\u0442\u0440\u043e\u0447\u0435\u043a \u043a\u043e\u0434\u0430, \u0447\u0442\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0442\u0430\u043c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u0430 \u0442\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u043d\u043e\u0432\u043e\u0435 \u0437\u0430\u043d\u0438\u043c\u0430\u043b\u043e \u043a\u043e\u043b\u043e\u0441\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u043c\u043e\u0434\u0435\u043b\u044f\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u0442\u0430\u043a \u0436\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u043b \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 <em>\u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f<\/em> \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445. \u0427\u0435\u0441\u0442\u043d\u043e \u0441\u043a\u0430\u0436\u0443, \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u0442\u044f\u0436\u0435\u043b\u043e.<\/p>\n<p>\u0417\u0430\u0442\u0435\u043c \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f <a href=\"https:\/\/developer.android.com\/topic\/libraries\/data-binding\" rel=\"noopener noreferrer nofollow\"><strong>DataBinding<\/strong><\/a> \u0438 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u043f\u043e \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u044e \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u043b\u0430\u0441\u044c \u043d\u0430 \u043d\u0435\u0433\u043e, \u043d\u043e \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u044b \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u0432\u0440\u0443\u0447\u043d\u0443\u044e, \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0438\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0442\u043e\u0434\u044b <code>onCreateViewHolder<\/code>, \u0433\u0434\u0435 \u0432\u043c\u0435\u0441\u0442\u043e \u0438\u043d\u0444\u043b\u044d\u0439\u0442\u0438\u043d\u0433\u0430 \u0447\u0435\u0440\u0435\u0437 <code>LayoutInflater<\/code>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f <code>DataBindingUtil.inflate<\/code>, \u0430 \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 <em>\u0432\u044c\u044e\u0445\u043e\u043b\u0434\u0435\u0440\u043e\u0432<\/em> \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043b\u0438\u0441\u044c \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441 \u0441\u0430\u043c\u043e\u0439 \u0432\u044c\u044e\u0448\u043a\u043e\u0439 \u0447\u0435\u0440\u0435\u0437 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0431\u0430\u0439\u0434\u0438\u043d\u0433\u0430.<\/p>\n<pre><code class=\"kotlin\">class BindingViewHolder(val binding: ItemTextRowBinding) : RecyclerView.ViewHolder(binding.root)  override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BindingViewHolder {         val binding = DataBindingUtil.inflate&lt;ItemTextRowBinding&gt;(LayoutInflater.from(parent.context), viewType, parent, false)         val viewHolder = BindingViewHolder(binding)         return viewHolder }  override fun onBindViewHolder(holder: BindingViewHolder, position: Int) {       holder.binding.setVariable(BR.item, dataSet[position]) }<\/code><\/pre>\n<p>\u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0443\u0436\u0435 \u043b\u0443\u0447\u0448\u0435, \u043d\u043e \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0432 RV, \u043f\u043e \u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c\u0441\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043b\u0430\u0439\u0430\u0443\u0442\u0430 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u0442\u043e \u0442\u0430\u043a\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0435 \u0441\u0438\u043b\u044c\u043d\u043e \u043f\u043e\u043c\u043e\u0433\u043b\u0430 \u0440\u0435\u0448\u0438\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u043e\u0432. \u0418 \u0437\u0434\u0435\u0441\u044c \u043d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f <a href=\"https:\/\/developer.android.com\/reference\/android\/databinding\/BindingAdapter\" rel=\"noopener noreferrer nofollow\"><strong>BindingAdapter<\/strong><\/a> \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <em>androidx.databinding. <\/em>\u0421 \u0435\u0435 \u043f\u043e\u043c\u043e\u0449\u044c\u044e, \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430 \u0434\u043b\u044f RV, \u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442-\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0442\u043e\u0440 <code>DataBindingRecyclerViewConfig<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0440\u044f\u0434 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0434\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430.<\/p>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043d\u0430 \u0441\u0432\u0435\u0442 \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <a href=\"https:\/\/github.com\/Rasalexman\/easy-recycler-binding\" rel=\"noopener noreferrer nofollow\">EasyRecyclerBinding<\/a>. \u0412 \u043d\u0435\u0435 \u0442\u0430\u043a \u0436\u0435 \u0432\u043e\u0448\u043b\u0438 <a href=\"https:\/\/developer.android.com\/reference\/android\/databinding\/BindingAdapter\" rel=\"noopener noreferrer nofollow\"><strong>BindingAdapters<\/strong><\/a> \u0434\u043b\u044f <em>ViewPager<\/em> \u0438 <em>ViewPager2<\/em>. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<br \/>1) \u0412 \u043b\u0430\u0439\u0430\u0443\u0442\u0435 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e, \u0443\u043a\u0430\u0437\u0430\u0432 \u0438\u0445 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c\u0438 \u0434\u043b\u044f RV, &#8212; <code>app:items<\/code> \u0438 <code>app:rv_config<\/code>.  <\/p>\n<pre><code class=\"xml\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt; &lt;layout xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"     xmlns:app=\"http:\/\/schemas.android.com\/apk\/res-auto\"     xmlns:tools=\"http:\/\/schemas.android.com\/tools\"&gt;      &lt;data&gt;     \t&lt;variable         \tname=\"vm\"         \ttype=\"com.rasalexman.erb.ui.base.ExampleViewModel\" \/&gt;          &lt;variable             name=\"rvConfig\"             type=\"com.rasalexman.easyrecyclerbinding.DataBindingRecyclerViewConfig\" \/&gt;     &lt;\/data&gt;      &lt;androidx.constraintlayout.widget.ConstraintLayout         android:id=\"@+id\/main\"         android:layout_width=\"match_parent\"         android:layout_height=\"match_parent\"&gt;          &lt;androidx.recyclerview.widget.RecyclerView             android:layout_width=\"0dp\"             android:layout_height=\"0dp\"             app:items=\"@{vm.items}\"             app:rv_config=\"@{rvConfig}\"             app:layout_constraintBottom_toBottomOf=\"parent\"             app:layout_constraintEnd_toEndOf=\"parent\"             app:layout_constraintStart_toStartOf=\"parent\"             app:layout_constraintTop_toTopOf=\"parent\"             tools:listitem=\"@layout\/item_recycler\"\/&gt;      &lt;\/androidx.constraintlayout.widget.ConstraintLayout&gt; &lt;\/layout&gt;<\/code><\/pre>\n<p>ViewModel, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c\u0441\u044f \u0432 RV, \u0430 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e DataBindingRecyclerViewConfig.<\/p>\n<pre><code class=\"kotlin\">\/\/ \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u044b \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u043f\u0440\u0438\u043c\u0435\u0440\u0430 class ExampleViewModel : ViewModel() {      val items: MutableLiveData&lt;MutableList&lt;RecyclerItemUI&gt;&gt; = MutableLiveData() }  data class RecyclerItemUI(     val id: String,     val title: String )<\/code><\/pre>\n<p>\u0421\u0430\u043c \u043b\u0430\u0439\u0430\u0443\u0442 \u0434\u043b\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0441\u043f\u0438\u0441\u043a\u0430, \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u0430\u043d\u043d\u044b\u0445, \u0447\u0442\u043e\u0431\u044b \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u0438\u0445 \u0432\u043c\u0435\u0441\u0442\u0435.<\/p>\n<pre><code class=\"xml\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt; &lt;layout xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"     xmlns:app=\"http:\/\/schemas.android.com\/apk\/res-auto\"     xmlns:tools=\"http:\/\/schemas.android.com\/tools\"&gt;      &lt;data&gt;          &lt;variable             name=\"item\"             type=\"com.rasalexman.erb.models.RecyclerItemUI\" \/&gt;     &lt;\/data&gt;      &lt;androidx.constraintlayout.widget.ConstraintLayout         android:layout_width=\"match_parent\"         android:layout_height=\"wrap_content\"         android:background=\"@android:drawable\/list_selector_background\"&gt;          &lt;TextView             android:id=\"@+id\/titleTV\"             android:layout_width=\"match_parent\"             android:layout_height=\"wrap_content\"             android:paddingStart=\"16dp\"             android:paddingTop=\"8dp\"             android:paddingEnd=\"16dp\"             android:textColor=\"@color\/black\"             android:textSize=\"18sp\"             android:text=\"@{item.title}\"             app:layout_constraintEnd_toEndOf=\"parent\"             app:layout_constraintStart_toStartOf=\"parent\"             app:layout_constraintTop_toTopOf=\"parent\"             tools:text=\"Hello world\" \/&gt;          &lt;TextView             android:layout_width=\"match_parent\"             android:layout_height=\"wrap_content\"             android:paddingStart=\"16dp\"             android:paddingEnd=\"16dp\"             android:paddingBottom=\"8dp\"             android:textColor=\"@color\/gray\"             android:textSize=\"14sp\"             android:text=\"@{item.id}\"             app:layout_constraintEnd_toEndOf=\"parent\"             app:layout_constraintStart_toStartOf=\"parent\"             app:layout_constraintTop_toBottomOf=\"@+id\/titleTV\"             tools:text=\"Hello world\" \/&gt;      &lt;\/androidx.constraintlayout.widget.ConstraintLayout&gt; &lt;\/layout&gt;<\/code><\/pre>\n<p>2) \u0412\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0435\u0451 \u0432  \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 \u0438\u043d\u0441\u0442\u0430\u043d\u0441 <em>dataBinding<\/em>, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e-\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 <code>createRecyclerConfig&lt;I : Any, BT : ViewDataBinding&gt;<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u0438 \u0432\u0435\u0440\u043d\u0435\u0442  \u0438\u043d\u0441\u0442\u0430\u043d\u0441 <em>DataBindingRecyclerViewConfig<\/em>, \u0443\u043a\u0430\u0437\u0430\u0432 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c id \u043b\u0430\u0439\u0430\u0443\u0442\u0430 \u0434\u043b\u044f \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438, \u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u0430 \u0434\u0430\u043d\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c.<\/p>\n<pre><code class=\"kotlin\">class RecyclerViewExampleFragment : BaseBindingFragment&lt;RvExampleFragmentBinding, ExampleViewModel&gt;() {       override val layoutId: Int get() = R.layout.rv_example_fragment   override val viewModel: ExampleViewModel by viewModels()          override fun initBinding(binding: RvExampleFragmentBinding) {         super.initBinding(binding)         binding.rvConfig = createRecyclerConfig&lt;RecyclerItemUI, ItemRecyclerBinding&gt; {             layoutId = R.layout.item_recycler         \t\titemId = BR.item                     }     } }<\/code><\/pre>\n<p>\u042d\u0442\u043e \u0432\u0441\u0435, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 ViewModel \u0441 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u0441\u043f\u0438\u0441\u043a\u0430 \u0432 RV. \u0422\u0430\u043a \u0436\u0435 \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0437\u043d\u0430\u0447\u0438\u0442\u044c \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0434\u043b\u044f \u0431\u0430\u0439\u0434\u0438\u043d\u0433\u0430 <em>\u0432\u044c\u044e\u0445\u043e\u043b\u0434\u0435\u0440\u0430<\/em>, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a <code>onItemClick,&nbsp;onItemCreate, onItemBind<\/code> &nbsp;\u0438 \u0434\u0440\u0443\u0433\u0438\u0435. <\/p>\n<p>\u0410 \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <em>\u0432\u044c\u044e\u0445\u043e\u043b\u0434\u0435\u0440\u044b<\/em> \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043b\u0430\u0439\u0430\u0443\u0442\u0430\u043c\u0438, \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u044b \u0441\u0432\u043e\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u043d\u0438\u0445 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <a href=\"https:\/\/github.com\/Rasalexman\/easy-recycler-binding\" rel=\"noopener noreferrer nofollow\">EasyRecyclerBinding<\/a> &#8212; <code>IBindingModel<\/code>&nbsp;\u0438 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u043e\u043b\u0435 <code>layoutResId<\/code>,  &#8212; id \u043b\u0430\u0439\u0430\u0443\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435. <\/p>\n<pre><code class=\"kotlin\">data class RecyclerItemUI(     \t\tval id: String,     val title: String ) : IBindingModel {         override val layoutResId: Int             \t\tget() = R.layout.item_recycler } data class RecyclerItemUI2(     val id: String,     val title: String ) : IBindingModel {     override val layoutResId: Int         get() = R.layout.item_recycler2 }<\/code><\/pre>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u043b\u044f \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 <em>\u0432\u044c\u044e\u0445\u043e\u043b\u0434\u0435\u0440\u0430\u043c\u0438<\/em> \u043d\u0435 \u0441\u0438\u043b\u044c\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0432\u044b\u0448\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0439, \u043a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u0440\u0443\u0433\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f-\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 <code>createRecyclerMultiConfig<\/code> \u0434\u043b\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0430\u0434\u0430\u043f\u0442\u0435\u0440\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0443\u0436\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0442\u0438\u043f \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0431\u0430\u0439\u0434\u0438\u043d\u0433\u0430.<\/p>\n<pre><code class=\"kotlin\">class RecyclerViewExampleFragment : BaseBindingFragment&lt;RvExampleFragmentBinding, RecyclerViewExampleViewModel&gt;() {       override val layoutId: Int get() = R.layout.rv_example_fragment     override val viewModel: RecyclerViewExampleViewModel by viewModels()          override fun initBinding(binding: RvExampleFragmentBinding) {         super.initBinding(binding)         binding.rvConfig = createRecyclerMultiConfig {             itemId = BR.item         }     } }  class RecyclerViewExampleViewModel : BasePagesViewModel() {     open val items: MutableLiveData&lt;MutableList&lt;IBindingModel&gt;&gt; = MutableLiveData() }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435<\/p>\n<\/p>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-319999","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/319999","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=319999"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/319999\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=319999"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=319999"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=319999"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}