Kotlin Topics Overview
Kotlin Topics Overview
1. Spinner in Kotlin
A Spinner in Android is a dropdown list that allows users to choose a single item from a set of
options.
Example:
```
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
spinner.adapter = adapter
override fun onItemSelected(parent: AdapterView<*>, view: View, position: Int, id: Long) {
```
2. ArrayAdapter in Kotlin
ArrayAdapter in Android is used to populate a view (such as ListView, GridView, or Spinner) with
```
listView.adapter = adapter
```
Example:
```
interface Clickable {
fun onClick()
println("Button clicked!")
```
Uses of Interface:
- Provides abstraction.
```
class Outer {
```
```
```
5. RelativeLayout in Kotlin
RelativeLayout positions its children relative to each other or the parent layout.
Example:
```
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView 1"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView 2"
android:layout_below="@id/textView1"
android:layout_alignParentEnd="true" />
</RelativeLayout>
```
Properties:
parent.
parent.
Advantages:
Disadvantages: