【发布时间】:2016-03-22 12:16:24
【问题描述】:
我有一个(自定义)SeekBar 嵌套在 RelativeLayout 和 LinearLayout 中,显示为 ListView 的项目。现在,只要我在onProgressChanged 中更新TextView(通过setText),我就会收到ACTION_CANCEL,并且我在SeekBar 上的移动/拖动被取消。如果不更新TextView,则可以正常工作。
知道有什么问题吗?
layout.xml的内容:
<LinearLayout>
<LinearLayout>
<RelativeLayout>
<TextView />
<SeekBar />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
自定义SeekBar中的代码:
@Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
if (fromUser) {
mProgressTextView.setText(String.valueOf(progress));
}
}
顺便说一句:这个问题只出现在 Android 6 上。在以前的版本上运行良好。
【问题讨论】:
-
你能把你的代码放上去吗
-
您是否使用倍数覆盖您的进度参数并除以 increamentProgressBy 值。就像 progress = progress / increamentProgressBy ;
-
那种。此 SeekBar 的目的是选择 16 到 28 度之间的温度,步长为 0.5 度。所以 SeekBar 的值/进度在 [0, 12] 中,它映射到温度并显示在 TextView 中。进度本身不受操纵