yfbx-repo / x-adapter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

x-adapter

License

Dependency:

dependencies {
    implementation 'com.github.yfbx-repo:x-adapter:1.1.4'
}

LayoutContainer Support

androidExtensions {
    experimental = true
}

Example:

//单布局
val adapter = recycleView.bind(R.layout.item_menu, data) { helper, item ->
    helper.btn.text = item.name
}

//多布局
recycleView.bind {
     bind<CharSequence>(R.layout.item_menu_test, "Group-1") { helper, item ->
         val textView = helper.textView
         textView.setBackgroundResource(R.color.background)
         textView.setTextColor(Color.BLACK)
         textView.gravity = Gravity.START
         textView.text = item
     }
     bind<User>(R.layout.item_menu, data) { helper, item ->
         helper.btn.text = item.name
         helper.btn.setOnClickListener {
             //
         }
     }
     add("Group-2")
     bind<Int>(R.layout.item_menu_test, listOf(1, 2, 3)) { helper, item ->
         helper.textView.text = "test$item"
     }
     add("Group-3")
     addAll(data)

     combine<CharSequence, String>()
     combine<CharSequence, SpannableString>()

     add(SpannableString("test"))
}

About

License:GNU General Public License v3.0


Languages

Language:Kotlin 100.0%