0% found this document useful (0 votes)
22 views1 page

Android UI Selections Display Code

The document contains an XML layout for an Android application with various UI components including a TextView, CheckBox, RadioGroup, Spinner, and Switch. The MainActivity class initializes these components and sets up an event listener for a button that displays the state of the UI elements in a TextView. The Spinner is populated with three items, and the button click updates the TextView with the current selections and states of the components.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views1 page

Android UI Selections Display Code

The document contains an XML layout for an Android application with various UI components including a TextView, CheckBox, RadioGroup, Spinner, and Switch. The MainActivity class initializes these components and sets up an event listener for a button that displays the state of the UI elements in a TextView. The Spinner is populated with three items, and the button click updates the TextView with the current selections and states of the components.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

android:text="Display Selections"

app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/spinner"
tools:layout_editor_absoluteX="0dp" />

<TextView
android:id="@+id/resultTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="16dp"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/displayButton"
tools:layout_editor_absoluteX="0dp" />

</[Link]>

[Link]

import [Link]
import [Link].*
import [Link]

class MainActivity : AppCompatActivity() {

@SuppressLint("MissingInflatedId")
override fun onCreate(savedInstanceState: Bundle?) {
[Link](savedInstanceState)
setContentView([Link].activity_main)

val checkBox: CheckBox = findViewById([Link])


val radioGroup: RadioGroup = findViewById([Link])
val spinner: Spinner = findViewById([Link])
val switchToggle: Switch = findViewById([Link].switch1)
val btn: Button = findViewById([Link])
val resultTextView: TextView = findViewById([Link])

val items = arrayOf("item1", "item2", "item3")


val adapter = ArrayAdapter(this, [Link].simple_spinner_item, items)
[Link] = adapter
[Link]{
val c = if([Link]) "Checked" else "Not Checked"
val RR = [Link]
val R = findViewById<RadioButton>(RR).[Link]()
val sp = [Link]()
val sw = if([Link]) "On" else "Off"

[Link] = " C => $c \nR => $R \nsp => $sp \nsw => $sw"
}

}
}

You might also like