我在我的片段中添加了一个SeekBar:
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState){
View view = inflater.inflate(R.layout.my_fragment, container, false);
seekbar1 = (SeekBar) view.findViewById(R.id.seekBar1);
seekbar1.setOnSeekBarChangeListener(new OnSeekBarChangeListener(){
int progressChanged = 0;
@Override
public void onStopTrackingTouch(SeekBar seekBar) {}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {}
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser){
if (fromUser){
progressChanged = progress;
Toast.makeText(VesselFragment.this.getActivity(), "Ingots: " + progressChanged, Toast.LENGTH_SHORT).show();
}
}
});
return view;
}
这是我的XML:
<SeekBar
android:id="@+id/seekBar1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:max="20" />
问题是:
当我沿着我的搜索栏拖动时,它只会在我放开手指时更新。
当我沿着我的搜索栏拖动时,它有时会改变其最大值。有几次我把酒吧一直拖到右边,我的Toast说进展是5或类似的东西。
当我沿着我的搜索栏拖动时,有时会发生我释放手指后,我的Toast显示值会发生变化。变化是随机的,有时它从当前值向下变化然后停止并上升然后变为某个随机值 并继续。
我不知道是什么原因造成他的。
编辑:这是垃圾邮件引起的垃圾邮件,当我甚至不接触电话时:07-20 20:09:40.723: D/ProgressBar(21895): setProgress = 9, fromUser = true
07-20 20:09:40.723: D/ProgressBar(21895): mProgress = 9mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:40.738: D/ProgressBar(21895): setProgress = 9, fromUser = true
07-20 20:09:40.738: D/ProgressBar(21895): mProgress = 9mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:40.758: D/ProgressBar(21895): setProgress = 9, fromUser = true
07-20 20:09:40.758: D/ProgressBar(21895): mProgress = 9mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:40.773: D/ProgressBar(21895): setProgress = 9, fromUser = true
07-20 20:09:40.773: D/ProgressBar(21895): mProgress = 9mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:40.788: D/ProgressBar(21895): setProgress = 9, fromUser = true
07-20 20:09:40.788: D/ProgressBar(21895): mProgress = 9mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:40.873: D/ProgressBar(21895): setProgress = 9, fromUser = true
07-20 20:09:40.873: D/ProgressBar(21895): mProgress = 9mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:42.093: D/ProgressBar(21895): setProgress = 15, fromUser = true
07-20 20:09:42.093: D/ProgressBar(21895): mProgress = 9mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:42.138: D/ProgressBar(21895): setProgress = 15, fromUser = true
07-20 20:09:42.138: D/ProgressBar(21895): mProgress = 15mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:42.158: D/ProgressBar(21895): setProgress = 15, fromUser = true
07-20 20:09:42.158: D/ProgressBar(21895): mProgress = 15mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:42.173: D/ProgressBar(21895): setProgress = 15, fromUser = true
07-20 20:09:42.173: D/ProgressBar(21895): mProgress = 15mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:42.208: D/ProgressBar(21895): setProgress = 15, fromUser = true
07-20 20:09:42.208: D/ProgressBar(21895): mProgress = 15mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:42.223: D/ProgressBar(21895): setProgress = 16, fromUser = true
07-20 20:09:42.223: D/ProgressBar(21895): mProgress = 15mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:42.238: D/ProgressBar(21895): setProgress = 16, fromUser = true
07-20 20:09:42.238: D/ProgressBar(21895): mProgress = 16mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:42.258: D/ProgressBar(21895): setProgress = 17, fromUser = true
07-20 20:09:42.258: D/ProgressBar(21895): mProgress = 16mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:42.273: D/ProgressBar(21895): setProgress = 17, fromUser = true
07-20 20:09:42.273: D/ProgressBar(21895): mProgress = 17mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:42.288: D/ProgressBar(21895): setProgress = 18, fromUser = true
07-20 20:09:42.288: D/ProgressBar(21895): mProgress = 17mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:42.308: D/ProgressBar(21895): setProgress = 18, fromUser = true
07-20 20:09:42.308: D/ProgressBar(21895): mProgress = 18mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:42.323: D/ProgressBar(21895): setProgress = 19, fromUser = true
07-20 20:09:42.323: D/ProgressBar(21895): mProgress = 18mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:42.338: D/ProgressBar(21895): setProgress = 19, fromUser = true
07-20 20:09:42.338: D/ProgressBar(21895): mProgress = 19mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:42.358: D/ProgressBar(21895): setProgress = 19, fromUser = true
07-20 20:09:42.358: D/ProgressBar(21895): mProgress = 19mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:42.373: D/ProgressBar(21895): setProgress = 19, fromUser = true
07-20 20:09:42.373: D/ProgressBar(21895): mProgress = 19mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:42.388: D/ProgressBar(21895): setProgress = 19, fromUser = true
07-20 20:09:42.388: D/ProgressBar(21895): mProgress = 19mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:42.408: D/ProgressBar(21895): setProgress = 19, fromUser = true
07-20 20:09:42.408: D/ProgressBar(21895): mProgress = 19mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:42.423: D/ProgressBar(21895): setProgress = 19, fromUser = true
07-20 20:09:42.423: D/ProgressBar(21895): mProgress = 19mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:42.438: D/ProgressBar(21895): setProgress = 19, fromUser = true
07-20 20:09:42.438: D/ProgressBar(21895): mProgress = 19mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:42.573: D/ProgressBar(21895): setProgress = 19, fromUser = true
07-20 20:09:42.573: D/ProgressBar(21895): mProgress = 19mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:42.588: D/ProgressBar(21895): setProgress = 19, fromUser = true
07-20 20:09:42.588: D/ProgressBar(21895): mProgress = 19mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:42.593: D/ProgressBar(21895): setProgress = 19, fromUser = true
07-20 20:09:42.593: D/ProgressBar(21895): mProgress = 19mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:43.203: D/ProgressBar(21895): setProgress = 17, fromUser = true
07-20 20:09:43.203: D/ProgressBar(21895): mProgress = 19mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:43.243: D/ProgressBar(21895): setProgress = 16, fromUser = true
07-20 20:09:43.243: D/ProgressBar(21895): mProgress = 17mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:43.258: D/ProgressBar(21895): setProgress = 16, fromUser = true
07-20 20:09:43.258: D/ProgressBar(21895): mProgress = 16mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:43.273: D/ProgressBar(21895): setProgress = 15, fromUser = true
07-20 20:09:43.273: D/ProgressBar(21895): mProgress = 16mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:43.288: D/ProgressBar(21895): setProgress = 15, fromUser = true
07-20 20:09:43.288: D/ProgressBar(21895): mProgress = 15mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:43.308: D/ProgressBar(21895): setProgress = 14, fromUser = true
07-20 20:09:43.308: D/ProgressBar(21895): mProgress = 15mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:43.323: D/ProgressBar(21895): setProgress = 13, fromUser = true
07-20 20:09:43.323: D/ProgressBar(21895): mProgress = 14mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:43.338: D/ProgressBar(21895): setProgress = 12, fromUser = true
07-20 20:09:43.338: D/ProgressBar(21895): mProgress = 13mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:43.358: D/ProgressBar(21895): setProgress = 12, fromUser = true
07-20 20:09:43.358: D/ProgressBar(21895): mProgress = 12mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:43.373: D/ProgressBar(21895): setProgress = 11, fromUser = true
07-20 20:09:43.373: D/ProgressBar(21895): mProgress = 12mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:43.388: D/ProgressBar(21895): setProgress = 10, fromUser = true
07-20 20:09:43.388: D/ProgressBar(21895): mProgress = 11mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:43.408: D/ProgressBar(21895): setProgress = 9, fromUser = true
07-20 20:09:43.408: D/ProgressBar(21895): mProgress = 10mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:43.423: D/ProgressBar(21895): setProgress = 8, fromUser = true
07-20 20:09:43.423: D/ProgressBar(21895): mProgress = 9mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:43.443: D/ProgressBar(21895): setProgress = 8, fromUser = true
07-20 20:09:43.443: D/ProgressBar(21895): mProgress = 8mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:43.458: D/ProgressBar(21895): setProgress = 7, fromUser = true
07-20 20:09:43.458: D/ProgressBar(21895): mProgress = 8mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:43.473: D/ProgressBar(21895): setProgress = 7, fromUser = true
07-20 20:09:43.473: D/ProgressBar(21895): mProgress = 7mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:43.493: D/ProgressBar(21895): setProgress = 6, fromUser = true
07-20 20:09:43.493: D/ProgressBar(21895): mProgress = 7mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:43.508: D/ProgressBar(21895): setProgress = 6, fromUser = true
07-20 20:09:43.508: D/ProgressBar(21895): mProgress = 6mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:43.523: D/ProgressBar(21895): setProgress = 5, fromUser = true
07-20 20:09:43.523: D/ProgressBar(21895): mProgress = 6mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:43.538: D/ProgressBar(21895): setProgress = 5, fromUser = true
07-20 20:09:43.538: D/ProgressBar(21895): mProgress = 5mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:43.558: D/ProgressBar(21895): setProgress = 5, fromUser = true
07-20 20:09:43.558: D/ProgressBar(21895): mProgress = 5mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:43.573: D/ProgressBar(21895): setProgress = 4, fromUser = true
07-20 20:09:43.573: D/ProgressBar(21895): mProgress = 5mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:43.588: D/ProgressBar(21895): setProgress = 4, fromUser = true
07-20 20:09:43.588: D/ProgressBar(21895): mProgress = 4mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:43.608: D/ProgressBar(21895): setProgress = 4, fromUser = true
07-20 20:09:43.608: D/ProgressBar(21895): mProgress = 4mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:43.613: D/ProgressBar(21895): setProgress = 4, fromUser = true
07-20 20:09:43.613: D/ProgressBar(21895): mProgress = 4mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:43.613: D/ProgressBar(21895): setProgress = 4, fromUser = true
07-20 20:09:43.613: D/ProgressBar(21895): mProgress = 4mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:48.368: D/ProgressBar(21895): setProgress = 12, fromUser = true
07-20 20:09:48.368: D/ProgressBar(21895): mProgress = 4mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:48.473: D/ProgressBar(21895): setProgress = 12, fromUser = true
07-20 20:09:48.473: D/ProgressBar(21895): mProgress = 12mIndeterminate = false, mMin = 0, mMax = 20
07-20 20:09:48.478: D/ProgressBar(21895): setProgress = 12, fromUser = true
07-20 20:09:48.478: D/ProgressBar(21895): mProgress = 12mIndeterminate = false, mMin = 0, mMax = 20