androidからwindowsにubsで画像を送る

Use UBS for

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

        getOmikujiButton.setOnClickListener {
            Log.v("MainActivity", "Button Clilcked")

            // Code here executes on main thread after user presses button
        }
    }

getOmikujiButton.setOnClickListener {
            val results = arrayOf("大吉","吉","中吉","小吉","凶")
            val n = Random().nextInt(results.count())

            resultTextView.text = results.get(n)
            // Code here executes on main thread after user presses button
        }

若干抵抗が少なくなってきました。

分岐処理

getOmikujiButton.setOnClickListener {
            val results = arrayOf("大吉","吉","中吉","小吉","凶")
            val n = Random().nextInt(results.count())

            if(n == 0){
                resultTextView.setTextColor(Color.RED)
            } else{
                resultTextView.setTextColor(Color.parseColor("#808080"))
            }

            resultTextView.text = results.get(n)
            // Code here executes on main thread after user presses button
        }

OK、では応用してみましょう。