diff --git a/app/src/main/java/net/helcel/beendroid/ListAdapter.kt b/app/src/main/java/net/helcel/beendroid/ListAdapter.kt new file mode 100644 index 0000000..9efdd1d --- /dev/null +++ b/app/src/main/java/net/helcel/beendroid/ListAdapter.kt @@ -0,0 +1,36 @@ +package net.helcel.beendroid + +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.CheckBox +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView + +class ListAdapter(private val dataSet: List) : + RecyclerView.Adapter() { + + class ViewHolder(view: View) : RecyclerView.ViewHolder(view) { + val textView: TextView + val checkBox: CheckBox + + init { + textView = view.findViewById(R.id.textView) + checkBox = view.findViewById(R.id.checkBox) + } + } + + override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): ViewHolder { + val view = LayoutInflater.from(viewGroup.context) + .inflate(R.layout.item_list, viewGroup, false) + + return ViewHolder(view) + } + + override fun onBindViewHolder(viewHolder: ViewHolder, position: Int) { + viewHolder.textView.text = dataSet[position] + } + + override fun getItemCount() = dataSet.size + +} diff --git a/app/src/main/java/net/helcel/beendroid/MainActivity.kt b/app/src/main/java/net/helcel/beendroid/MainActivity.kt index 3ddeb82..caeb86b 100644 --- a/app/src/main/java/net/helcel/beendroid/MainActivity.kt +++ b/app/src/main/java/net/helcel/beendroid/MainActivity.kt @@ -6,14 +6,19 @@ import android.os.Bundle import android.view.View import androidx.annotation.Nullable import androidx.appcompat.app.AppCompatActivity +import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.ListAdapter +import androidx.recyclerview.widget.RecyclerView import com.caverock.androidsvg.SVG import com.caverock.androidsvg.SVGImageView +import net.helcel.beendroid.R import java.nio.charset.StandardCharsets class MainActivity : AppCompatActivity() { - private var map : SVGImageView? = null + private lateinit var map : SVGImageView + private lateinit var list : RecyclerView override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -21,7 +26,6 @@ class MainActivity : AppCompatActivity() { setContentView(R.layout.activity_main) map = findViewById(R.id.map) - val cm = HashMap() Country.values().forEach { c-> cm[c] = SVGWrapper(applicationContext,c,Level.ZERO).load() @@ -35,7 +39,10 @@ class MainActivity : AppCompatActivity() { canvas.drawRGB(255, 255, 255) svg.renderToCanvas(canvas) - map?.setImageBitmap(bitmap) + map.setImageBitmap(bitmap) + list = findViewById(R.id.list) + list.layoutManager = LinearLayoutManager(applicationContext, RecyclerView.VERTICAL, false) + list.adapter = ListAdapter(Country.values().map{ it.code }) } } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 0bc5fbf..e55fe94 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -12,4 +12,11 @@ android:layout_weight="1" app:css="" /> + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_list.xml b/app/src/main/res/layout/item_list.xml new file mode 100644 index 0000000..40be8c5 --- /dev/null +++ b/app/src/main/res/layout/item_list.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + \ No newline at end of file