Advertisement
Diaxon

MainActivity.kt

Sep 28th, 2023 (edited)
899
0
130 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 0.91 KB | None | 0 0
  1. package com.example.myapplication
  2.  
  3. import androidx.appcompat.app.AppCompatActivity
  4. import android.os.Bundle
  5. import android.view.View
  6. import android.webkit.WebView
  7. import android.widget.CheckBox
  8. import android.widget.EditText
  9.  
  10. class MainActivity : AppCompatActivity() {
  11.     override fun onCreate(savedInstanceState: Bundle?) {
  12.         super.onCreate(savedInstanceState)
  13.         setContentView(R.layout.activity_main)
  14.         val animals_input = findViewById<EditText>(R.id.animals_input)
  15.         val webView: WebView = findViewById(R.id.webview)
  16.         webView.loadUrl("https://github.com")
  17.  
  18.         val checkbox = findViewById<CheckBox>(R.id.animals)
  19.  
  20.         checkbox.setOnCheckedChangeListener { _, isChecked ->
  21.             if (isChecked) {
  22.                 animals_input.visibility = View.VISIBLE
  23.             } else {
  24.                 animals_input.visibility = View.GONE
  25.             }
  26.         }
  27.  
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement