问题
I have a list view where each textview is supposed to show the value of the seekbar. I have got it working such that once the onStopTrackingTouch is called for a seekbar I update the corresponding textview. I would like for the change to occur as the user is moving the seekbar but I am having trouble doing the same as the listview doesn't refresh that often.

What would be an ideal method to achieve this?
回答1:
You can call notifyDataSetChanged
on OnSeekBarChangeListener
Hope this help.
回答2:
So here is what I did , I defined a touch listener outside of getView , set it as the TouchListener for seekbar in getview. The TouchListener returns the view as an argument , I got the view's parent and the did a findViewByID search for the tectview and updated it.
回答3:
I found a way to achieve this behavior, when i override the ArrayAdapter´s getView()
method, i set the SeekBar tag attribute with the position of the current item. so it helps me to extract the corresponding item when onProgressChanged(...)
callback is executed. at the same time it lets me update the correspondant object inside which is contained in the adapter.
sbProgress.setTag(position);
sbProgress.setOnSeekBarChangeListener(new OnSeekBarChangeListener(){
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
View view = (View) seekBar.getParent();
if(view != null){
TextView tvProgress = (TextView)view.findViewById(R.id.tv_porcentaje_numerico_obtenido);
tvProgress.setText(progress + "%");
MyAdapter.this.getItem((Integer)seekBar.getTag()).setProgres(progress);
}
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {}
});
Here is an image which explain what i mean

I hope this can be helpful to someone.
来源:https://stackoverflow.com/questions/6297791/refresh-seekbar-textview-in-a-listview