2012-03-23 28 views

回答

6

你不应该一次又一次地创造行(getView()法)..

@Override 
    public View getView(int position, View arg1, ViewGroup parent) { 
     // TODO Auto-generated method stub 

      LayoutInflater inflater = getLayoutInflater(); 
      View row = arg1; 
      if(row==null) 
       { 
       row = inflater.inflate(R.layout.listview_item_row, parent, false); 

       } 
      // Log.d("position", ""+str[position]); 
       Button b1 = (Button)row.findViewById(R.id.btn); 
       final SeekBar s1 = (SeekBar)row.findViewById(R.id.seekBar1); 
       //s1.setFocusable(true); 
       b1.setText(str[position]); 
        b1.setOnClickListener(new OnClickListener() 
        { 
        public void onClick(View v) { 

         Toast.makeText(getApplicationContext(), "Progress is "+s1.getProgress()+"%", Toast.LENGTH_LONG).show(); 

        } 

        }); 

     return row; 
} 
0

那么我有这个相同的问题,到目前为止,我一直无法解决它。

我在SeekBar onStartTrackingTouch中尝试了几件事情,在我的ScrollView上设置了名为quickScroll的Scoll。这在设置滚动方面起作用,但每当seekBar上的进度发生变化时,ScrollView都会迅速重置,然后返回到设置位置。

@Override 
    public void onStartTrackingTouch(SeekBar seekBar) { 

      quickScroll.post(new Runnable() { 
       @Override 
       public void run() { 

        //quickScroll.requestDisallowInterceptTouchEvent(true); 
        //quickScroll.setEnabled(false); 
        quickScroll.scrollTo(0, 54); 
        // quickScroll.requestDisallowInterceptTouchEvent(true); 
       } 
      }); 


    } 

在许多其他的东西,你可以看但是,当onLayout被调用我的自定义的ViewGroup它重置滚动到(0,0)。就像它的立场一样,我的onLayout()会在每次按下按钮时调用,但只有在SeekBar更改时才会重置ScrollView。请让我知道你是否找到了解决办法。