2013-01-22 2 views
1

각 행에 SeekBarTextView이 포함 된 행이있는 ListView이 있습니다. SeekBar 중 하나를 이동할 때마다 TextViewListView에있는 내용을 SeekBar에 집중하지 않고 업데이트해야합니다.SeekBar 포커스를 잃지 않고 ListView 행을 업데이트하십시오.

나는 ListView

  • 전화 notifyDataSetChanged()을 시도하지만, SeekBar 포커스를 잃게됩니다. 다음 코드로 ListView 통해

  • 루프 :

    for (int i = 0; i < listView.getChildCount(); i++) 
    { 
    TextView tv = (TextView) listView.getChildAt(i).findViewById(R.id.textView1); 
    String value = getData(); 
    tv.setText(value); 
    } 
    

그러나, 위의 코드를 사용자가 스크롤하면 문제가있는 ListView에 지속적인 갱신을 제공하지 않습니다.

이 문제를 해결하는 방법에 대한 제안 사항이 있으십니까?

답변

1

나는 중 하나를 이동할 때마다 검색 막대의 내가 가지고하는 데 필요한 모든 텍스트 뷰의 에서 SeekBar에 초점을 잃지 않고, 라이브 업데이트 ListView에있다. 당신이 notifyDataSetChanged()를 호출하고 또한 현재 가시 행에서 TextViews를 업데이트하지 않고 어댑터의 데이터 목록을 업데이트하고 싶은 무엇

.

//... 
@Override 
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { 
    // found is a reference to the ListView  
    int firstVisible = found.getFirstVisiblePosition(); 
    // first update the mData which backs the adapter    
    for (int i = 0; i < mData.size(); i++) { 
      // update update update 
    } 
    // update the visible rows 
    for (int j = 0; j < found.getChildCount(); j++) { 
      final View row = found.getChildAt(j); 
      // get the position from the mData by offseting j with the firstVisible position 
     ((TextView) row.findViewById(R.id.theIdOfTheTextView)).setText(mData.get(firstVisible + j)); 
    } 
} 
//... 

이렇게하면 원활한 업데이트가 제공됩니다.

+0

감사합니다. 그것은 내가 필요로했던 바로 그 것이었다. –

+0

당신은 내가 어댑터를 지원하는 데이터를 업데이트하는 것을 잊어 버렸다는 것을 알게되었습니다. –

관련 문제