【发布时间】:2021-07-22 23:43:47
【问题描述】:
所以我有一个搜索栏,我希望搜索栏的值显示在屏幕上,但 android studio 不明白我描述搜索栏和文本的 ID 是什么(ID 被星号包围)
所有被星号包围的代码都是红色的,解释器看不懂。有什么帮助吗?
class MainActivity : AppCompatActivity() {
private var textView: TextView? = null
private var progressBar: ProgressBar? = null
private var seekBar: SeekBar? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.*activity_mq1*)
textView = findViewById<View>(R.id.*textViewQ1*) as TextView
progressBar = findViewById<View>(R.id.*progressBar*) as ProgressBar
seekBar = findViewById<View>(R.id.*seekBarQ1*) as SeekBar
seekBar!!.setOnSeekBarChangeListener(object : OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
progressBar!!.progress = progress
textView!!.text = "$progress%"
}
override fun onStartTrackingTouch(seekBar: SeekBar) {}
override fun onStopTrackingTouch(seekBar: SeekBar) {}
})
}
【问题讨论】:
标签: java android android-studio kotlin