mirror of
https://github.com/AdrianKuta/Expandable-RecyclerView.git
synced 2025-04-20 07:29:02 +02:00
* 6: Use data model instead of String. Remove databinding. * 6: Use online lib dependency * 6: Remove CircleCI
38 lines
1.1 KiB
Kotlin
38 lines
1.1 KiB
Kotlin
package com.github.adriankuta
|
|
|
|
import android.os.Bundle
|
|
import androidx.appcompat.app.AppCompatActivity
|
|
import com.github.adriankuta.databinding.ActivityMainBinding
|
|
import com.github.adriankuta.expandable_recyclerview.expandableTree
|
|
|
|
class MainActivity : AppCompatActivity() {
|
|
|
|
private lateinit var binding: ActivityMainBinding
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
super.onCreate(savedInstanceState)
|
|
binding = ActivityMainBinding.inflate(layoutInflater)
|
|
setContentView(binding.root)
|
|
|
|
val tree = expandableTree(Region("World")) {
|
|
child(Region("North America")) {
|
|
child(Region("USA"))
|
|
}
|
|
child(Region("Europe")) {
|
|
child(Region("Poland")) {
|
|
child(Region("Warsaw"))
|
|
}
|
|
child(Region("Germany"))
|
|
}
|
|
child(Region("Asia")) {
|
|
child(Region("China"))
|
|
}
|
|
}
|
|
|
|
val adapter = ExpandableAdapter()
|
|
binding.recyclerView.adapter = adapter
|
|
adapter.setTree(tree)
|
|
}
|
|
}
|