我正在尝试在调用onseeking方法时将搜索栏进度设置为arraylist中的预定值,但是这里的问题是,搜索栏没有从arraylist中搜索到所需位置,然后在最大位置发生碰撞。我真的被困住了,将不胜感激。
这是我的搜索栏已更改:
fun seekbarseek(){
customseekbar.setOnSeekChangeListener(object : OnSeekChangeListener {
override fun onSeeking(seekParams: SeekParams) {
if (seekParams.progress<=progresslist!!.get(1))
{
Log.i("seekpos:","0")
zoomin()
customseekbar.onSeekChangeListener = null
}
else if (seekParams.progress>progresslist!!.get(1)&&seekParams.progress<=progresslist!!.get(2))
{
Log.i("seekpos:","1")
zoomin()
customseekbar.onSeekChangeListener = null
}
else if (seekParams.progress>progresslist!!.get(2)&&seekParams.progress<=progresslist!!.get(3))
{
Log.i("seekpos:","2")
zoomin()
customseekbar.onSeekChangeListener = null
}
else if (seekParams.progress>progresslist!!.get(3)&&seekParams.progress<=progresslist!!.get(4))
{
Log.i("seekpos:","3")
zoomin()
customseekbar.onSeekChangeListener = null
}
}
override fun onStartTrackingTouch(seekBar: IndicatorSeekBar) {
}
override fun onStopTrackingTouch(seekBar: IndicatorSeekBar) {
if (seekBar.progress<=progresslist!!.get(1))
{
customseekbar.setProgress(progresslist!!.get(1).toFloat())
customseekbar.onSeekChangeListener = null
}
else if (seekBar.progress>progresslist!!.get(1)&&seekBar.progress<=progresslist!!.get(2))
{
customseekbar.setProgress(progresslist!!.get(2).toFloat())
}
else if (seekBar.progress>progresslist!!.get(2)&&seekBar.progress<=progresslist!!.get(3))
{
customseekbar.setProgress(progresslist!!.get(3).toFloat())
}
else if (seekBar.progress>progresslist!!.get(3)&&seekBar.progress<=progresslist!!.get(4))
{
customseekbar.setProgress(progresslist!!.get(4).toFloat())
}
}
})
These is my arraylist content:
progresslist!!.add(0)
progresslist!!.add(calprogress+calprogress)
progresslist!!.add(calprogress+calprogress+calprogress)
progresslist!!.add(calprogress+calprogress+calprogress+calprogress)
progresslist!!.add(calprogress+calprogress+calprogress+calprogress+calprogress)
这是我在寻找搜寻栏时要调用的方法:
fun zoomin()
{
Log.i("zoominposition", zoomposition.toString())
if (zoomposition == 5)
{
zoomposition = 4
setfocus()
}
zoomposition++
customseekbar.setProgress(progresslist!!.get(zoomposition).toFloat())
}
答案 0 :(得分:0)
首先尝试为进度栏设置最大值
customseekbar.setMax(maxValue);
然后您的setProgress
将正常工作