Android(Kotlin 語言)開發(fā)一個(gè)簡(jiǎn)單的計(jì)數(shù)器應(yīng)用




二、Android(Kotlin 語言)
同樣是一個(gè)簡(jiǎn)單的計(jì)數(shù)器應(yīng)用,有一個(gè)文本視圖顯示計(jì)數(shù),一個(gè)按鈕增加計(jì)數(shù)。
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.TextView
class MainActivity : AppCompatActivity() {
private var count = 0
private lateinit var countTextView: TextView
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
countTextView = findViewById(R.id.countTextView)
countTextView.text = "Count: $count"
}
fun incrementCount(view: View) {
count++
countTextView.text = "Count: $count"
}
}
相關(guān)推薦
- iOS(Swift 語言)創(chuàng)建一個(gè)簡(jiǎn)單的計(jì)數(shù)器應(yīng)用
- 網(wǎng)站和應(yīng)用如何選用服務(wù)器?
- 阿里云的輕量應(yīng)用服務(wù)器和云服務(wù)器有什么區(qū)別?
- Fabric Hyperledger實(shí)戰(zhàn):用Go語言搭建Web應(yīng)用與區(qū)塊鏈
- 今天介紹一個(gè)非常流行的Django: Python Web應(yīng)用開發(fā)框
- 銀聯(lián)權(quán)益分銷平臺(tái)行業(yè)應(yīng)用接口開發(fā)實(shí)例(php語言)
- SEO之簡(jiǎn)略標(biāo)題的應(yīng)用
- 小心身邊的山寨應(yīng)用-移動(dòng)支付有陷阱
- 移動(dòng)應(yīng)用行業(yè)規(guī)范即將出臺(tái)!!!手機(jī)APP有望清場(chǎng)
- Android銷量巨大”但“Android問題多多