SeekBar 的 onProgressChanged 在我的 Kotlin/Android Studio 中不使用描述性参数
自动生成的代码是 onProgressChanged(p0: SeekBar?, p1: Int, p2: Boolean),而不是 onProgressChanged(< strong>seekBar:SeekBar?,进度:Int,fromUser:布尔值)与其他网站和Youtube教程一样,在Kotlin中点击“实现成员”后(Kotlin插件版本:1.4.32-release-Studio4.1-1,检查更新后Android Studio设置中显示的最新版本)。该函数运行良好,但如果有描述性参数就更好了。如何设置系统让它显示描述性参数?先感谢您!
代码:
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.SeekBar
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
idSeekBar.setOnSeekBarChangeListener(object:SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(p0: SeekBar?, p1: Int, p2: Boolean) {
tvShowData.text = p1.toString() }
override fun onStartTrackingTouch(p0: SeekBar?) { }
override fun onStopTrackingTouch(p0: SeekBar?) { }
})
}
}
The automatically generated code is onProgressChanged(p0: SeekBar?, p1: Int, p2: Boolean), instead of onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) as in other websites and Youtube tutorials, after clicking "implement members" in Kotlin (Kotlin plugin version: 1.4.32-release-Studio4.1-1, the latest version shown in Android Studio Settings after check update). The function works well, but it would be better if it has descriptive parameters. How to set the system to let it show the descriptive parameters? Thank you in advance!
The code:
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.SeekBar
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
idSeekBar.setOnSeekBarChangeListener(object:SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(p0: SeekBar?, p1: Int, p2: Boolean) {
tvShowData.text = p1.toString() }
override fun onStartTrackingTouch(p0: SeekBar?) { }
override fun onStopTrackingTouch(p0: SeekBar?) { }
})
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
原因是你没有下载当前的android api sdk。例如在android studio中,通过
ctrl + space
可以看到setOnSeekBarChangeListener
的定义,android studio会告诉你可以下载api sdk。下载后,您可以再次尝试。希望有用。The reason is you don't have downloaded current api sdk for android. In android studio, for example, you can see the defination of
setOnSeekBarChangeListener
byctrl + space
, and android studio will tell you that you can download api sdk. After downloading, you can try it again. Hopes useful.