1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Android Studio For Beginners Part 1をKotlinでやってみた(初心者向け)

Last updated at Posted at 2020-01-24

背景

Android Studio For Beginners Part 1 (https://www.youtube.com/watch?v=dFlPARW5IX8) を動画に沿ってやってみた。

本動画での使用言語はJavaだったが、私はKotlinを選択した。途中からJavaでコーディングする工程があり、Kotlinに変換する作業に苦戦したので、備忘録として残しておく。

コード

MainActivity.kt

package com.example.myapplication

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)


        this.addBtn.setOnClickListener{
            var num1 = this.firstNumEditText.text.toString().toInt()
            var num2 = this.secondNumEditText.text.toString().toInt()
            var result = num1 + num2
            this.resultTextView.text = result.toString()
        }
    }
}
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?