gpt-4-0314· OpenAI
WildChat-4.8M (AI2)
KOTLIN中 寫一個介面 打開後 有一個按鈕 按下去 會說 OK
- User
KOTLIN中 寫一個介面 打開後 有一個按鈕 按下去 會說 OK
- Assistant
在 Kotlin 中,你可以通過以下步驟創建一個含有按鈕的 Android 介面:
第 1 步:創建一個新的 Android Studio 項目,並選擇 Kotlin 語言。
第 2 步:在
res/layout目錄下的activity_main.xml文件中,編輯 XML 以創建按鈕:<?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <Button android:id="@+id/button_ok" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="OK" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> </androidx.constraintlayout.widget.ConstraintLayout>