Open fjr619 opened 4 years ago
Hi, @fjr619 You can implement it using the below example codes.
class SampleAdapter0(private val delegate: SampleViewHolder.Delegate) : BaseAdapter() {
private val section_item = 0
init {
addSection(ArrayList<SampleItem>())
}
fun addItems(sampleItems: List<SampleItem>) {
addItemsOnSection(section_item, sampleItems)
notifyDataSetChanged()
}
override fun layout(sectionRow: SectionRow): Int {
// if the sectionRow.row % 2 == 0, returns view_even.xml
// else return view_odd.xml
}
override fun viewHolder(layout: Int, view: View): BaseViewHolder {
return SampleViewHolder(view, delegate)
}
}
what is different between addSection
addSectionList
addItemOnSection
addItemListOnSection
, because the documentation still confusing. thank you
I tried :
val section = mutableListOf<String>()
section.add("test 1")
section.add("test 2")
section.add("test 3")
addSection(section)
for (index in 0 until sections().size){
addItemListOnSection(index, sampleItems)
}
but when i tried to log sections().size
, the value is 1
why? should it be 3 right?
example : i need make 3 section, each section have 5 item
Next question how to remove item? sorry for too much question, because this libs is good and want to maximize the usage in my project
How to make just use 1 section like in example, but with multi layout child. example if position is even then use view_even.xml, and if position is odd then use view_odd.xml ? thank you