如何从活动中的适配器的getveiw()访问搜索栏视图

时间:2013-09-20 14:12:59

标签: android listview seekbar

我想在填充listview的活动中从适配器的getveiw()访问seekbar。

适配器中的

getview():

if (convertView == null) {

        LayoutInflater inflator = context.getLayoutInflater();
        convertView = inflator.inflate(R.layout.row, null);
        viewHolder = new ViewHolder();
        viewHolder.seekbar= (SeekBar) convertView.findViewById(R.id.seekBar1);
        viewHolder.seekbar.setOnSeekBarChangeListener( myseekbarlistener);
        viewHolder.time_txt= (TextView) convertView.findViewById(R.id.textView1);
}           

2 个答案:

答案 0 :(得分:0)

试试这个,像这样创建一个构造函数

  public Top15Adapter(Top15Stocks top15Stocks, OnSeekBarChangeListener listner) {
    // TODO Auto-generated constructor stub
    this.OnSeekBarChangeListener = listher;
}


listher.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

        private int progressChanged = 0;

        @Override
        public void onStopTrackingTouch(SeekBar arg0) {
            // TODO Auto-generated method stub
            Toast.makeText(Activityname.this,
                    "seek bar progress:" + progressChanged,
                    Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onStartTrackingTouch(SeekBar arg0) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onProgressChanged(SeekBar arg0, int arg1,
                boolean fromuser) {
            // TODO Auto-generated method stub
            progressChanged = arg1;
        }
    });

答案 1 :(得分:0)

如果您想更新搜索栏进度,那么只需

viewHolder.seekbar.setProgress(value);

或者你的意思是其他什么?