Refresh seekbar + textview in a listview

旧街凉风 提交于 2019-12-07 00:48:34

You can call notifyDataSetChanged

on OnSeekBarChangeListener

Hope this help.

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!