class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) val myButton: Button = findViewById(R.id.myButton) val myText: TextView = findViewById(R.id.textView) myButton.setOnClickListener { myText.text = "Hello, Kotlin!" } } } Use code with caution. Copied to clipboard 6. Running and Debugging : Click the Green Hammer icon to compile. Run : Click the Green Play icon to launch on the emulator.
: Defines app permissions and essential components. 4. Designing the User Interface (UI) Build A Simple Android App With Kotlin
Android uses (Extensible Markup Language) to define layouts. The most flexible layout is the ConstraintLayout . Example: A Simple Button and Text In activity_main.xml , you might define: TextView : To display a greeting. Button : To trigger an action. Run : Click the Green Play icon to launch on the emulator
: This is the official IDE (Integrated Development Environment). Designing the User Interface (UI) Android uses (Extensible
: Set up an Android Virtual Device (AVD) via the Device Manager to test your app without a physical phone. 2. Creating a New Project