{"id":1003,"date":"2024-11-09T06:41:10","date_gmt":"2024-11-09T06:41:10","guid":{"rendered":"https:\/\/www.freelifemakers.org\/wordpress\/?p=1003"},"modified":"2024-11-09T08:07:41","modified_gmt":"2024-11-09T08:07:41","slug":"kotlin-kinder-app1-text-view-examp","status":"publish","type":"post","link":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/2024\/11\/09\/kotlin-kinder-app1-text-view-examp\/","title":{"rendered":"[Kotlin]\ubc84\ud2bc\ud074\ub9ad,\ud1a0\uc2a4\ud2b8\uba54\uc138\uc9c0,\ud14d\uc2a4\ud2b8\ubdf0 \uc608\uc81c\/Button click, toast message, text view examples"},"content":{"rendered":"\n<p>\ub354 \uce5c\uc808\ud55c \ucf54\ud2c0\ub9b0 \uc571\ud504\ub85c\uadf8\ub798\ubc0d \ucc45\uc5d0 \uc788\ub294 \ucf54\ub4dc \uc785\ub2c8\ub2e4.<br>This is code from the Friendlier Kotlin App Programming book<\/p>\n\n\n\n<p>\ubc84\ud2bc\ud074\ub9ad,\ud1a0\uc2a4\ud2b8 \uba54\uc2dc\uc9c0,\ud14d\uc2a4\ud2b8\ubdf0 \ucf54\ub4dc \uc608\uc81c \uc785\ub2c8\ub2e4.<br>Button click, toast message, and text view code examples<\/p>\n\n\n\n<p>\uc774 \ucf54\ub4dc\ub294 \ubdf0\ubc14\uc778\ub529\uc744 \uc0ac\uc6a9\ud558\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.<br>This code does not use view binding.<\/p>\n\n\n\n<p>Test : compileSdk = 34 targetSdk = 34<\/p>\n\n\n\n<p>MainActivity.kt<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>package com.example.app1\n\nimport android.os.Bundle\nimport android.widget.Button\nimport android.widget.EditText\nimport android.widget.TextView\nimport android.widget.Toast\nimport androidx.activity.enableEdgeToEdge\nimport androidx.appcompat.app.AppCompatActivity\nimport androidx.core.view.ViewCompat\nimport androidx.core.view.WindowInsetsCompat\n\n\nclass MainActivity : AppCompatActivity() {\n    override fun onCreate(savedInstanceState: Bundle?) {\n        super.onCreate(savedInstanceState)\n        enableEdgeToEdge()\n        setContentView(R.layout.activity_main)\n\n        \n        val button = findViewById&lt;Button&gt;(R.id.button)\n        val button2 = findViewById&lt;Button&gt;(R.id.button2)\n        val input1 = findViewById&lt;EditText&gt;(R.id.input1)\n        val output1 = findViewById&lt;TextView&gt;(R.id.output1)\n\n        button.setOnClickListener(){\n            Toast.makeText(this@MainActivity,\"show Toast Message\",Toast.LENGTH_SHORT).show()\n        }\n\n        button2.setOnClickListener(){\n            val inputText1 = input1.text.toString()\n            output1.text = \"\uacb0\uacfc : $inputText1\"\n        }\n\n        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets -&gt;\n            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())\n            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)\n            insets\n        }\n    }\n}<\/code><\/pre>\n\n\n\n<p>active_main.xml<\/p>\n\n\n\n<p>-xml design<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"430\" height=\"647\" src=\"https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2024\/11\/App1.png\" alt=\"\" class=\"wp-image-1008\" srcset=\"https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2024\/11\/App1.png 430w, https:\/\/www.freelifemakers.org\/wordpress\/wp-content\/uploads\/2024\/11\/App1-199x300.png 199w\" sizes=\"auto, (max-width: 430px) 100vw, 430px\" \/><\/figure>\n\n\n\n<p>-xml code<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\n&lt;androidx.constraintlayout.widget.ConstraintLayout xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\n    xmlns:app=\"http:\/\/schemas.android.com\/apk\/res-auto\"\n    xmlns:tools=\"http:\/\/schemas.android.com\/tools\"\n    android:id=\"@+id\/main\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    tools:context=\".MainActivity\"&gt;\n\n    &lt;Button\n        android:id=\"@+id\/button\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:text=\"\ud655\uc778\"\n        app:layout_constraintBottom_toBottomOf=\"parent\"\n        app:layout_constraintEnd_toEndOf=\"parent\"\n        app:layout_constraintStart_toStartOf=\"parent\"\n        app:layout_constraintTop_toTopOf=\"parent\"\n        app:layout_constraintVertical_bias=\"0.335\" \/&gt;\n\n    &lt;EditText\n        android:id=\"@+id\/input1\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:layout_marginTop=\"20dp\"\n        android:ems=\"10\"\n        android:inputType=\"text\"\n        android:text=\"Name Text\"\n        app:layout_constraintEnd_toEndOf=\"parent\"\n        app:layout_constraintHorizontal_bias=\"0.497\"\n        app:layout_constraintStart_toStartOf=\"parent\"\n        app:layout_constraintTop_toBottomOf=\"@+id\/button\" \/&gt;\n\n    &lt;Button\n        android:id=\"@+id\/button2\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:layout_marginTop=\"92dp\"\n        android:text=\"Button\"\n        app:layout_constraintEnd_toEndOf=\"parent\"\n        app:layout_constraintHorizontal_bias=\"0.496\"\n        app:layout_constraintStart_toStartOf=\"parent\"\n        app:layout_constraintTop_toBottomOf=\"@+id\/input1\" \/&gt;\n\n    &lt;TextView\n        android:id=\"@+id\/output1\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:text=\"\uacb0\uacfc\"\n        android:textColor=\"#CC4318\"\n        android:textSize=\"50sp\"\n        app:layout_constraintBottom_toBottomOf=\"parent\"\n        app:layout_constraintEnd_toEndOf=\"parent\"\n        app:layout_constraintHorizontal_bias=\"0.498\"\n        app:layout_constraintStart_toStartOf=\"parent\"\n        app:layout_constraintTop_toBottomOf=\"@+id\/button2\"\n        app:layout_constraintVertical_bias=\"0.291\" \/&gt;\n\n&lt;\/androidx.constraintlayout.widget.ConstraintLayout&gt;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\ub354 \uce5c\uc808\ud55c \ucf54\ud2c0\ub9b0 \uc571\ud504\ub85c\uadf8\ub798\ubc0d \ucc45\uc5d0 \uc788\ub294 \ucf54\ub4dc \uc785\ub2c8\ub2e4.This is code from the Friendlier Kotlin App Programming book \ubc84\ud2bc\ud074\ub9ad,\ud1a0\uc2a4\ud2b8 \uba54\uc2dc\uc9c0,\ud14d\uc2a4\ud2b8\ubdf0 \ucf54\ub4dc \uc608\uc81c \uc785\ub2c8\ub2e4.Button click, toast message, and text view code examples \uc774 \ucf54\ub4dc\ub294 \ubdf0\ubc14\uc778\ub529\uc744 \uc0ac\uc6a9\ud558\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4.This code does not use view binding. Test : compileSdk = 34 targetSdk = 34 MainActivity.kt active_main.xml -xml design -xml code<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,1],"tags":[],"class_list":["post-1003","post","type-post","status-publish","format-standard","hentry","category-kotlin","category-uncategorized","missing-thumbnail"],"_links":{"self":[{"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/1003","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/comments?post=1003"}],"version-history":[{"count":10,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/1003\/revisions"}],"predecessor-version":[{"id":1035,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/1003\/revisions\/1035"}],"wp:attachment":[{"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/media?parent=1003"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/categories?post=1003"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/tags?post=1003"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}